Skip to content

Commit

Permalink
Merge pull request #23 from jeromegamez/code-inspection
Browse files Browse the repository at this point in the history
Ameliorate IDE support
  • Loading branch information
lolautruche committed May 20, 2015
2 parents 7bddb71 + fc16a06 commit bf3a81c
Show file tree
Hide file tree
Showing 29 changed files with 142 additions and 84 deletions.
4 changes: 2 additions & 2 deletions bin/php/sqlidoimport.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
$script->initialize();
$script->setUseDebugAccumulators( true );

include_once 'extension/sqliimport/modules/sqliimport/sigtermhandler.php';
include_once 'extension/sqliimport/modules/sqliimport/fatalerrorhandler.php';
include_once __DIR__ . '/../../modules/sqliimport/sigtermhandler.php';
include_once __DIR__ . '/../../modules/sqliimport/fatalerrorhandler.php';

try
{
Expand Down
5 changes: 4 additions & 1 deletion classes/content/options/sqlicontentoptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct( array $options = array() )

parent::__construct( $options );
}

/**
* Sets the option $optionName to $optionValue.
* Supported options for content are :
Expand All @@ -39,6 +39,9 @@ public function __construct( array $options = array() )
* - creator_id => Object creator UserID
* - language => Language for object
* @see lib/ezc/Base/src/ezcBaseOptions::__set()
* @param string $optionName
* @param mixed $optionValue
* @throws ezcBasePropertyNotFoundException
*/
public function __set( $optionName, $optionValue )
{
Expand Down
2 changes: 1 addition & 1 deletion classes/content/options/sqlicontentpublishoptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct( array $options = array() )

parent::__construct( $options );
}

/**
* (non-PHPdoc)
* @see lib/ezc/Base/src/ezcBaseOptions::__set()
Expand Down
29 changes: 18 additions & 11 deletions classes/content/sqlicontent.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* $article->fields->body = $xmlContent;
* </code>
*
* @property-read SQLILocationFieldset $locations Available locations for this content
* @property-read SQLILocationSet $locations Available locations for this content
* @property mixed All "attributes" available from eZContentObject (See {@link eZContentObject::definition()}).
*/
class SQLIContent
Expand All @@ -62,7 +62,7 @@ class SQLIContent

/**
* Fieldset Holder
* @var SQLIFieldsetHolder
* @var SQLIContentFieldsetHolder
*/
public $fields;

Expand Down Expand Up @@ -135,6 +135,8 @@ public function getRawContentObject()
* @param SQLIContentOptions $options See {@link SQLIContentOptions::__set()} to see available options.
* Mandatory parameters are :
* - class_identifier
* @return SQLIContent
* @throws SQLIContentException If a required option has not been set
*/
public static function create( SQLIContentOptions $options )
{
Expand Down Expand Up @@ -200,11 +202,12 @@ public static function fromContentObject( eZContentObject $object )

return $content;
}

/**
* Initializes an object from ContentObjectID
* @param int $objectID
* @return SQLIContent
* @throws SQLIContentException if the requested content object has not been found
*/
public static function fromContentObjectID( $objectID )
{
Expand Down Expand Up @@ -236,6 +239,7 @@ public static function fromNode( eZContentObjectTreeNode $node )
* Initializes an object from a nodeID
* @param int $nodeID
* @throws SQLIContentException
* @return SQLIContent
*/
public static function fromNodeID( $nodeID )
{
Expand Down Expand Up @@ -385,13 +389,14 @@ public function getDraft()
{
return $this->fields->getCurrentDraft( $this->activeLanguage );
}

/**
* Generic method for calling current content object methods.
* If method isn't implemented, will throw an exception
* @param $method Method name
* @param string $method Method name
* @param $arguments
* @throws ezcBasePropertyNotFoundException
* @return mixed
* @throws ezcBasePropertyNotFoundException if the requested method is not implemented
*/
public function __call( $method, $arguments )
{
Expand All @@ -400,13 +405,14 @@ public function __call( $method, $arguments )
else
throw new ezcBasePropertyNotFoundException( $method );
}

/**
* Getter
* Returns given attribute for current content object if it exists (ie. main_node_id).
* Will throw an exception otherwise.
* All "classic" attributes can be used (See {@link eZContentObject::definition()}).
* @param $name
* @param string $name
* @return SQLILocation|SQLILocationSet|mixed
* @throws ezcBasePropertyNotFoundException
*/
public function __get( $name )
Expand Down Expand Up @@ -446,8 +452,8 @@ public function __get( $name )
* Sets value to an attribute for the content object.
* All "classic" attributes can be used (See {@link eZContentObject::definition()}).
* If attribute doesn't exist, will throw an exception
* @param $name Attribute name
* @param $value Attribute value
* @param string $name Attribute name
* @param mixed $value Attribute value
* @throws ezcBasePropertyNotFoundException
* @return void
*/
Expand Down Expand Up @@ -490,12 +496,13 @@ public function remove( $moveToTrash = true )
$this->doRemove( $aNodesID, $moveToTrash );
$this->flush();
}

/**
* Removes only one location for content object.
* Location is identified by $nodeID
* @param int $nodeID A valid node ID
* @param bool $moveToTrash Indicates if we move content to trash or not. True by default
* @throws SQLIContentException if the requested node could not be fetched
*/
public function removeLocation( $nodeID, $moveToTrash = true )
{
Expand Down
6 changes: 4 additions & 2 deletions classes/content/sqlicontentfiedset.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SQLIContentFieldset implements Iterator
/**
* Reference to the fields of this fieldset
* Array indexed by attribute identifier
* @var array( SQLIContentField )
* @var SQLIContentField[]
*/
protected $fields = array();

Expand All @@ -33,8 +33,9 @@ class SQLIContentFieldset implements Iterator

/**
* Getter. Returns given field
* @param $name Attribute identifier
* @param string $name Attribute identifier
* @return SQLIContentField
* @throws SQLIContentException if the requested field does not exist.
*/
public function __get( $name )
{
Expand All @@ -51,6 +52,7 @@ public function __get( $name )
* Best results when datatype implements fromString() method (@see eZDataType::fromString())
* @param string $name Field name
* @param string $value Field string value
* @throws SQLIContentException if the requested field does not exist.
*/
public function __set( $name, $value )
{
Expand Down
14 changes: 8 additions & 6 deletions classes/content/sqlicontentfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ public static function fromContentObjectAttribute( eZContentObjectAttribute $att
/**
* Check if given attribute exists.
* All "classic" attributes can be used (See {@link eZContentObjectAttribute::definition()}).
* @param $name
* @param string $name
* @return bool
* @throws SQLIContentException if no content object attribute has beeen assigned to this content field
*/
public function __isset( $name )
{
Expand Down Expand Up @@ -126,8 +127,8 @@ public function __get( $name )
* Sets value to an attribute for the content object attribute.
* All "classic" attributes can be used (See {@link eZContentObjectAttribute::definition()}).
* If attribute doesn't exist, will throw an exception
* @param $name Attribute name
* @param $value Attribute value
* @param string $name Attribute name
* @param mixed $value Attribute value
* @throws ezcBasePropertyNotFoundException
* @return void
*/
Expand Down Expand Up @@ -167,8 +168,8 @@ public function __toString()
/**
* Generic method for calling current attribute methods
* If method isn't implemented, will throw an exception
* @param $method Method name
* @param $arguments
* @param string $method Method name
* @param array $arguments
* @throws ezcBasePropertyNotFoundException
* @return mixed
*/
Expand Down Expand Up @@ -319,11 +320,12 @@ public function toString()
{
return self::convertAttributeToString( $this->attribute );
}

/**
* Generic method wrapping datatype's toString() method if implemented
* Checks if toString() is implemented in the field's datatype
* If not, data_text will be used by default
* @param eZContentObjectAttribute $attribute
* @return string
*/
public static function convertAttributeToString( eZContentObjectAttribute $attribute )
Expand Down
7 changes: 5 additions & 2 deletions classes/content/sqlicontentfieldsetholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SQLIContentFieldsetHolder implements ArrayAccess, Iterator
/**
* Reference to the known children field sets
* Indexed by locale: xxx-XX => SQLIContentFieldset
* @var array( SQLIContentFieldset )
* @var SQLIContentFieldset[]
*/
protected $fieldsets = array();

Expand All @@ -40,6 +40,7 @@ class SQLIContentFieldsetHolder implements ArrayAccess, Iterator
* Checks if locale is registered for current SQLIContent
* offsetExists from ArrayAccess interface
* @param $offset
* @return bool
*/
public function offsetExists( $offset )
{
Expand All @@ -50,6 +51,7 @@ public function offsetExists( $offset )
* Returns SQLIContentFieldset for requested language
* offsetGet from ArrayAccess interface
* @param $offset
* @return SQLIContentFieldset
*/
public function offsetGet( $offset )
{
Expand All @@ -67,6 +69,7 @@ public function offsetGet( $offset )
* Fieldsets are readonly. Will throw an exception when trying to directly assign a value
* @param $offset
* @param $value
* @throws SQLIContentException
*/
public function offsetSet( $offset, $value )
{
Expand Down Expand Up @@ -236,7 +239,7 @@ public function addTranslation( $lang )
/**
* Returns current draft for current content object.
* If there is no current draft, a new one will be created in provided language.
* @param string $lang Valid locale xxx-XX. If not provided, default edit language will be used
* @param string|bool $lang Valid locale xxx-XX. If not provided, default edit language will be used
* @see eZContentObject::createNewVersionIn()
* @return eZContentObjectVersion
*/
Expand Down
9 changes: 6 additions & 3 deletions classes/content/sqlicontentpublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ public function setOptions( SQLIContentPublishOptions $options )
{
$this->options = $options;
}

/**
* Publishes provided content
* @param SQLIContent $content
* @throws SQLIContentException if the initial location or parent node have not been defined
*/
public function publish( SQLIContent $content )
{
Expand Down Expand Up @@ -196,14 +197,15 @@ public function contentIsModified( SQLIContent $content, $language = null )
eZDebug::accumulatorStop( 'sqlicontentpublisher_checkmodification' );
return $contentIsModified;
}

/**
* Checks if publication is "allowed" for provided content in provided language.
* Publication will be allowed if content has been modified (a diff is operated) or if modification check has
* been explicitly disabled with option "modification_check" to false.
* If language is not provided, the function will take {@link SQLIContent::getActiveLanguage() content active language}
* @param SQLIContent $content
* @param string $language Language to check modification for. Must be a valid locale (xxx-XX)
* @return bool
*/
protected function publicationAllowed( SQLIContent $content, $language = null )
{
Expand Down Expand Up @@ -272,12 +274,13 @@ private function createNewVersion( SQLIContent $content )

return $version;
}

/**
* Adds a location to provided content.
* Prefer using SQLIContent::addLocation() instead of calling this method directly
* @param SQLILocation $location
* @param SQLIContent $content
* @throws SQLIContentException
* @internal
*/
public function addLocationToContent( SQLILocation $location, SQLIContent $content )
Expand Down
24 changes: 17 additions & 7 deletions classes/ezxmltext/input/handlers/sqlixmlinputparser.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function breakInlineFlow( $element, &$param )
* seesm to be doing nothing
*
* @param DOMElement $element
* @param array $param parameters for xml element
* @param array $params parameters for xml element
* @return bool|null
*/
function initHandlerCustom( $element, &$params )
Expand All @@ -550,7 +550,7 @@ function initHandlerCustom( $element, &$params )
* sets anchor as attribute if setting is enabled
*
* @param DOMElement $element
* @param array $param parameters for xml element
* @param array $params parameters for xml element
* @return bool|null
*/
function initHandlerHeader( $element, &$params )
Expand Down Expand Up @@ -1064,7 +1064,7 @@ function structHandlerParagraph( $element, $newParent )
* Publish handler for link element, converts href to [object|node|link]_id.
*
* @param DOMElement $element
* @param array $param parameters for xml element
* @param array $params parameters for xml element
* @return null|array changes structure if it contains 'result' key
*/
function publishHandlerLink( $element, &$params )
Expand Down Expand Up @@ -1208,7 +1208,7 @@ function publishHandlerLink( $element, &$params )
* fixes align=middle value (if embed was image) and tries to map css to attributes
*
* @param DOMElement $element
* @param array $param parameters for xml element
* @param array $params parameters for xml element
* @return null|array changes structure if it contains 'result' key
*/
function publishHandlerEmbed( $element, &$params )
Expand Down Expand Up @@ -1284,19 +1284,29 @@ function processAttributesBySchema( $element )
parent::processAttributesBySchema( $element );
}

/*
/**
* Misc internally (by this and main xml handler) used functions
*/

/**
* @return array
*/
function getUrlIDArray()
{
return $this->urlIDArray;
}


/**
* @return array
*/
function getEmbeddedObjectIDArray()
{
return $this->embeddedObjectIDArray;
}


/**
* @return array
*/
function getLinkedObjectIDArray()
{
return $this->linkedObjectIDArray;
Expand Down
Loading

0 comments on commit bf3a81c

Please sign in to comment.