PHP Class Jackalope\Property

It has a single parent node and no children. A property consists of a name and a value, or in the case of multi-value properties, a set of values all of the same type.
Inheritance: extends Item, implements IteratorAggregate, implements PHPCR\PropertyInterface
Exibir arquivo Open project: jackalope/jackalope Class Usage Examples

Protected Properties

Property Type Description
$definition PHPCR\NodeType\PropertyDefinitionInterface cached instance of the property definition that defines this property
$isMultiple boolean whether this is a multivalue property
$length integer length is only used for binary property, because binary loading is delayed until explicitly requested.
$streams array All binary stream wrapper instances
$type integer the type constant from PropertyType
$value mixed The property value in suitable native format or object
$wrapBinaryStreams boolean flag to know if binary streams should be wrapped or retrieved immediately. this is a per session setting.

Public Methods

Method Description
__construct ( jackalope\FactoryInterface $factory, array $data, string $path, jackalope\Session $session, ObjectManager $objectManager, boolean $new = false ) Create a property, either from server data or locally
__destruct ( ) Close all open binary stream wrapper instances on shutdown.
_setLength ( integer $length ) Internally used after refresh from backend to set new length
_setValue ( mixed $value, integer | string $type = PropertyType::UNDEFINED, boolean $constructor = false ) Internally used to set the value of the property without any notification of changes nor state change.
addValue ( $value ) {@inheritDoc}
getBinary ( ) {@inheritDoc}
getBoolean ( ) {@inheritDoc}
getDate ( ) {@inheritDoc}
getDecimal ( ) {@inheritDoc}
getDefinition ( ) {@inheritDoc}
getDouble ( ) {@inheritDoc}
getIterator ( ) : Iterator Provide Traversable interface: redirect to getNodes with no filter
getLength ( ) {@inheritDoc}
getLong ( ) {@inheritDoc}
getNode ( ) {@inheritDoc}
getProperty ( ) {@inheritDoc}
getString ( ) {@inheritDoc}
getType ( ) {@inheritDoc}
getValue ( ) {@inheritDoc}
getValueForStorage ( ) Get the value of this property to store in the storage backend.
isMultiple ( ) {@inheritDoc}
remove ( ) Also unsets internal reference in containing node
setModified ( ) Tell this item that it has been modified.
setValue ( $value, $type = PropertyType::UNDEFINED ) {@inheritDoc}

Protected Methods

Method Description
refresh ( $keepChanges, $internal = false ) Refresh this property

Private Methods

Method Description
getReferencedNodes ( string[] $ids, boolean $weak ) : Node[] Get all nodes for $ids, ordered by that array, with duplicates if there are duplicates in $ids.

Method Details

__construct() public method

To indicate a property has newly been created locally, make sure to pass true for the $new parameter. In that case, you should pass an empty array for $data and use setValue afterwards to let the type magic be handled. Then multivalue is determined on setValue For binary properties, the value is the length of the data(s), not the data itself.
public __construct ( jackalope\FactoryInterface $factory, array $data, string $path, jackalope\Session $session, ObjectManager $objectManager, boolean $new = false )
$factory jackalope\FactoryInterface the object factory
$data array array with fields type (integer or string from PropertyType) and value (data for creating the property value - array for multivalue property)
$path string the absolute path of this item
$session jackalope\Session the session instance
$objectManager ObjectManager the objectManager instance - the caller has to take care of registering this item with the object manager
$new boolean optional: set to true to make this property aware its not yet existing on the server. defaults to false

__destruct() public method

Close all open binary stream wrapper instances on shutdown.
public __destruct ( )

_setLength() public method

Internally used after refresh from backend to set new length
public _setLength ( integer $length )
$length integer the new length of this binary

_setValue() public method

Internally used to set the value of the property without any notification of changes nor state change.
See also: Property::setValue()
public _setValue ( mixed $value, integer | string $type = PropertyType::UNDEFINED, boolean $constructor = false )
$value mixed The value to set.
$type integer | string PropertyType constant
$constructor boolean Whether this is called from the constructor.

addValue() public method

{@inheritDoc}
public addValue ( $value )

getBinary() public method

{@inheritDoc}
public getBinary ( )

getBoolean() public method

{@inheritDoc}
public getBoolean ( )

getDate() public method

{@inheritDoc}
public getDate ( )

getDecimal() public method

{@inheritDoc}
public getDecimal ( )

getDefinition() public method

{@inheritDoc}
public getDefinition ( )

getDouble() public method

{@inheritDoc}
public getDouble ( )

getIterator() public method

Provide Traversable interface: redirect to getNodes with no filter
public getIterator ( ) : Iterator
return Iterator over all child nodes

getLength() public method

{@inheritDoc}
public getLength ( )

getLong() public method

{@inheritDoc}
public getLong ( )

getNode() public method

{@inheritDoc}
public getNode ( )

getProperty() public method

{@inheritDoc}
public getProperty ( )

getString() public method

{@inheritDoc}
public getString ( )

getType() public method

{@inheritDoc}
public getType ( )

getValue() public method

{@inheritDoc}
public getValue ( )

getValueForStorage() public method

Path and reference properties are not resolved to the node objects. If this is a binary property, from the moment this method has been called the stream will be read from the transport layer again.
public getValueForStorage ( )

isMultiple() public method

{@inheritDoc}
public isMultiple ( )

refresh() protected method

{@inheritDoc} In Jackalope, this is also called internally to refresh when the node is accessed in state DIRTY. Triggers a reload of the containing node, as a property can only ever be loaded attached to a node. TODO: refactor this if we implement loading single properties
See also: Item::checkState
protected refresh ( $keepChanges, $internal = false )

remove() public method

{@inheritDoc}
public remove ( )

setModified() public method

Used to make the parent node aware that this property has changed
public setModified ( )

setValue() public method

{@inheritDoc}
public setValue ( $value, $type = PropertyType::UNDEFINED )

Property Details

$definition protected_oe property

cached instance of the property definition that defines this property
See also: Property::getDefinition()
protected PropertyDefinitionInterface,PHPCR\NodeType $definition
return PHPCR\NodeType\PropertyDefinitionInterface

$isMultiple protected_oe property

whether this is a multivalue property
protected bool $isMultiple
return boolean

$length protected_oe property

length is only used for binary property, because binary loading is delayed until explicitly requested.
protected int $length
return integer

$streams protected_oe property

All binary stream wrapper instances
protected array $streams
return array

$type protected_oe property

the type constant from PropertyType
protected int $type
return integer

$value protected_oe property

The property value in suitable native format or object
protected mixed $value
return mixed

$wrapBinaryStreams protected_oe property

flag to know if binary streams should be wrapped or retrieved immediately. this is a per session setting.
See also: Property::__construct()
protected bool $wrapBinaryStreams
return boolean