phpcr/src/PHPCR/PropertyInterface.php
Copyright 2008-2011 Karsten Dambekalns karsten@typo3.org
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\PHPCR\PropertyInterface
A Property object represents the smallest granularity of content storage. 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.
The \Traversable interface enables the implementation to be addressed with foreach. Properties have to implement either \IteratorAggregate or \Iterator. The iterator is equivalent to getValue() returning an iterator of all values of this property (which is exactly one except for multi-valued properties). The iterator keys have no significant meaning.
PHPCR Note: We removed the Value interface and consequently the getValue() and getValues() methods. If you just want the property value in its native type, use getValue, or just NodeInterface::getPropertyValue. The PropertyInterface::getXX methods also work for multi-valued properties. They return arrays in case of multi-valued. PropertyInterface::setValue completely replaces the ValueFactory::createValue method.
- Parent(s)
- \PHPCR\ItemInterface
- Api
Constants
JCR_PRIMARY_TYPE
= "{http://www.jcp.org/jcr/1.0}primaryType"
- Api
JCR_MIXIN_TYPES
= "{http://www.jcp.org/jcr/1.0}mixinTypes"
- Api
JCR_CONTENT
= "{http://www.jcp.org/jcr/1.0}content"
Note: jcr:content is also the name of a child node declared in nt:file.
- Api
JCR_DATA
= "{http://www.jcp.org/jcr/1.0}data"
- Api
JCR_PROTOCOL
= "{http://www.jcp.org/jcr/1.0}protocol"
- Api
JCR_HOST
= "{http://www.jcp.org/jcr/1.0}host"
- Api
JCR_PORT
= "{http://www.jcp.org/jcr/1.0}port"
- Api
JCR_REPOSITORY
= "{http://www.jcp.org/jcr/1.0repository"
- Api
JCR_WORKSPACE
= "{http://www.jcp.org/jcr/1.0}workspace"
- Api
JCR_PATH
= "{http://www.jcp.org/jcr/1.0}path"
- Api
JCR_ID
= "{http://www.jcp.org/jcr/1.0}id"
- Api
JCR_UUID
= "{http://www.jcp.org/jcr/1.0}uuid"
- Api
JCR_TITLE
= "{http://www.jcp.org/jcr/1.0}title"
- Api
JCR_DESCRIPTION
= "{http://www.jcp.org/jcr/1.0}description"
- Api
JCR_CREATED
= "{http://www.jcp.org/jcr/1.0}created"
- Api
JCR_CREATED_BY
= "{http://www.jcp.org/jcr/1.0}createdBy"
- Api
JCR_LAST_MODIFIED
= "{http://www.jcp.org/jcr/1.0}lastModified"
- Api
JCR_LAST_MODIFIED_BY
= "{http://www.jcp.org/jcr/1.0}lastModifiedBy"
- Api
JCR_LANGUAGE
= "{http://www.jcp.org/jcr/1.0}language"
- Api
JCR_MIMETYPE
= "{http://www.jcp.org/jcr/1.0}mimeType"
- Api
JCR_ENCODING
= "{http://www.jcp.org/jcr/1.0}encoding"
- Api
JCR_NODE_TYPE_NAME
= "{http://www.jcp.org/jcr/1.0}nodeTypeName"
- Api
JCR_SUPERTYPES
= "{http://www.jcp.org/jcr/1.0}supertypes"
- Api
JCR_IS_ABSTRACT
= "{http://www.jcp.org/jcr/1.0}isAbstract"
- Api
JCR_IS_MIXIN
= "{http://www.jcp.org/jcr/1.0}isMixin"
- Api
JCR_HAS_ORDERABLE_CHILD_NODES
= "{http://www.jcp.org/jcr/1.0}hasOrderableChildNodes"
- Api
JCR_PRIMARY_ITEM_NAME
= "{http://www.jcp.org/jcr/1.0}primaryItemName"
- Api
JCR_NAME
= "{http://www.jcp.org/jcr/1.0}name"
- Api
JCR_AUTOCREATED
= "{http://www.jcp.org/jcr/1.0}autoCreated"
- Api
JCR_MANDATORY
= "{http://www.jcp.org/jcr/1.0}mandatory"
- Api
JCR_PROTECTED
= "{http://www.jcp.org/jcr/1.0}protected"
- Api
JCR_ON_PARENT_VERSION
= "{http://www.jcp.org/jcr/1.0}onParentVersion"
- Api
JCR_REQUIRED_TYPE
= "{http://www.jcp.org/jcr/1.0}requiredType"
- Api
JCR_VALUE_CONSTRAINTS
= "{http://www.jcp.org/jcr/1.0}valueConstraints"
- Api
JCR_DEFAULT_VALUES
= "{http://www.jcp.org/jcr/1.0}defaultValues"
- Api
JCR_MULTIPLE
= "{http://www.jcp.org/jcr/1.0}multiple"
- Api
JCR_REQUIRED_PRIMARY_TYPES
= "{http://www.jcp.org/jcr/1.0}requiredPrimaryTypes"
- Api
JCR_DEFAULT_PRIMARY_TYPE
= "{http://www.jcp.org/jcr/1.0}defaultPrimaryType"
- Api
JCR_SAME_NAME_SIBLINGS
= "{http://www.jcp.org/jcr/1.0}sameNameSiblings"
- Api
JCR_LOCK_OWNER
= "{http://www.jcp.org/jcr/1.0}lockOwner"
- Api
JCR_LOCK_IS_DEEP
= "{http://www.jcp.org/jcr/1.0}lockIsDeep"
- Api
JCR_LIFECYCLE_POLICY
= "{http://www.jcp.org/jcr/1.0}lifecyclePolicy"
- Api
JCR_CURRENT_LIFECYCLE_STATE
= "{http://www.jcp.org/jcr/1.0}currentLifecycleState"
- Api
JCR_IS_CHECKED_OUT
= "{http://www.jcp.org/jcr/1.0}isCheckedOut"
- Api
JCR_FROZEN_PRIMARY_TYPE
= "{http://www.jcp.org/jcr/1.0}frozenPrimaryType"
- Api
JCR_FROZEN_MIXIN_TYPES
= "{http://www.jcp.org/jcr/1.0}frozenMixinTypes"
- Api
JCR_FROZEN_UUID
= "{http://www.jcp.org/jcr/1.0}frozenUuid"
- Api
JCR_VERSION_HISTORY
= "{http://www.jcp.org/jcr/1.0}versionHistory"
- Api
JCR_BASE_VERSION
= "{http://www.jcp.org/jcr/1.0}baseVersion"
- Api
JCR_PREDECESSORS
= "{http://www.jcp.org/jcr/1.0}predecessors"
- Api
JCR_MERGE_FAILED
= "{http://www.jcp.org/jcr/1.0}mergeFailed"
- Api
JCR_ACTIVITY
= "{http://www.jcp.org/jcr/1.0}activity"
- Api
JCR_CONFIGURATION
= "{http://www.jcp.org/jcr/1.0}configuration"
- Api
JCR_VERSIONABLE_UUID
= "{http://www.jcp.org/jcr/1.0}versionableUuid"
- Api
JCR_COPIED_FROM
= "{http://www.jcp.org/jcr/1.0}copiedFrom"
- Api
JCR_SUCCESSORS
= "{http://www.jcp.org/jcr/1.0}successors"
- Api
JCR_CHILD_VERSION_HISTORY
= "{http://www.jcp.org/jcr/1.0}childVersionHistory"
- Api
JCR_ROOT
= "{http://www.jcp.org/jcr/1.0}root"
- Api
Methods
accept(\PHPCR\ItemVisitorInterface $visitor) : void
This is less relevant in PHP (Java had it to avoid typecasting in the visitor). We leave it here, to allow sanity checks or other operations an implementation might wants to do.
Name | Type | Description |
---|---|---|
$visitor | \PHPCR\ItemVisitorInterface | The ItemVisitor to be accepted. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
addValue(mixed $value) : void
Appends a value to a multi-value property.
It is added at the end of the list.
PHPCR Note: This is a new method not found in Java JCR. In PHP appending to strings is easy and this is more convenient than getting the property and appending to the array and setting again.
Name | Type | Description |
---|---|---|
$value | mixed |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if the property is not multi-value. |
getAncestor(integer $depth) : \PHPCR\ItemInterface
Returns the ancestor of this Item at the specified depth.
Inherited from: \PHPCR\ItemInterface::getAncestor()An ancestor of depth x is the Item that is x levels down along the path from the root node to this Item.
- depth = 0 returns the root node of a workspace.
- depth = 1 returns the child of the root node along the path to this Item.
- depth = 2 returns the grandchild of the root node along the path to this Item.
- And so on to depth = n, where n is the depth of this Item, which returns this Item itself.
If this node has more than one path (i.e., if it is a descendant of a shared node) then the path used to define the ancestor is implementaion- dependent.
Name | Type | Description |
---|---|---|
$depth | integer | An integer, 0 <= depth <= n where n is the depth of this Item. |
Type | Description |
---|---|
\PHPCR\ItemInterface | The ancestor of this Item at the specified depth. |
Exception | Description |
---|---|
\PHPCR\ItemNotFoundException | if depth < 0 or depth > n where n is the depth of this item. |
\PHPCR\AccessDeniedException | if the current session does not have sufficient access to retrieve the specified node. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getBinary() : resource | array
Returns a Binary representation of the value of this property.
The Binary object in turn provides methods to access the binary data itself. Uses the standard conversion to binary (see JCR specification).
Type | Description |
---|---|
resource | array | A stream resource if the underlying binary |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if another error occurs |
- Api
getBoolean() : boolean | array
Returns a boolean representation of the value of this property.
PHP Note:Keep in mind that according to the specification, not all property types can be converted to boolean. Most actually can not be converted - see PropertyType::convertType(). If you want to know if a value is empty in the PHP sense, use getString() and do your checks on the string.
Type | Description |
---|---|
boolean | array | A boolean representation of the value of this property, or an array of boolean for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if conversion to a boolean is not possible |
\PHPCR\RepositoryException | if another error occurs |
- Api
getDate() : \DateTime | array
Returns a \DateTime representation of the value of this property.
The object returned is a copy of the stored value, so changes to it are not reflected in internal storage.
Type | Description |
---|---|
\DateTime | array | A date representation of the value of this property, or an array of DateTime for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if conversion to \DateTime is not possible |
\PHPCR\RepositoryException | if another error occurs |
- Api
getDecimal() : string | array
Returns an arbitrary precision number (encoded as string) representation of this value (a BigDecimal in Java).
The string must be encoded with the C locale because of http://bugs.php.net/bug.php?id=16532
Type | Description |
---|---|
string | array | A string representation of the value of this property, or an array of strings for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if conversion to a number string is not possible |
\PHPCR\RepositoryException | if another error occurs |
- Api
getDefinition() : \PHPCR\NodeType\PropertyDefinitionInterface
Returns the property definition that applies to this property.
In some cases there may appear to be more than one definition that could apply to this node. However, it is assumed that upon creation or change of this property, a single particular definition is chosen by the implementation. It is that definition that this method returns. How this governing definition is selected upon property creation or change from among others which may have been applicable is an implementation issue and is not covered by this specification.
Type | Description |
---|---|
\PHPCR\NodeType\PropertyDefinitionInterface | a PropertyDefinition object. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getDepth() : integer
Returns the depth of this Item in the workspace item graph.
Inherited from: \PHPCR\ItemInterface::getDepth()- The root node returns 0.
- A property or child node of the root node returns 1.
- A property or child node of a child node of the root returns 2.
- And so on to this Item.
Type | Description |
---|---|
integer | The depth of this Item in the workspace item graph. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getDouble() : float | array
Returns a float representation of the value of this property.
Type | Description |
---|---|
float | array | A float representation of the value of this property, or an array of float for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if conversion to a double is not possible |
\PHPCR\RepositoryException | if another error occurs |
- Api
getLength() : integer | array
Returns the length(s) of the value(s) of this property.
For a BINARY property, getLength returns the number of bytes. For other property types, getLength returns the same value that would be returned by calling strlen() on the value when it has been converted to a STRING according to standard JCR propety type conversion.
Returns -1 if the implementation cannot determine the length.
For multi-valuedproperties, the same rules apply, but returns an array of lengths with the same order as the values have in getValue.
Type | Description |
---|---|
integer | array | the length of this value, or an array of lengths for multi-valued properties |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getLong() : integer | array
Returns an integer representation of the value of this property.
Type | Description |
---|---|
integer | array | An integer representation of the value of this property, or an array of integer for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if conversion to integer is not possible |
\PHPCR\RepositoryException | if another error occurs |
- Api
getName() : string
Returns the name of this Item in qualified form.
Inherited from: \PHPCR\ItemInterface::getName()If this Item is the root node of the workspace, an empty string is returned.
Type | Description |
---|---|
string | the name of this Item in qualified form or an empty string if this Item is the root node of a workspace. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getNode() : \PHPCR\NodeInterface | array
Gets the node the property refers to by its type.
If this property is of type REFERENCE, WEAKREFERENCE or PATH (or convertible to one of these types) this method returns the Node to which this property refers. If this property is of type PATH and it contains a relative path, it is interpreted relative to the parent node of this property. For example "." refers to the parent node itself, ".." to the parent of the parent node and "foo" to a sibling node of this property.
If you do not want to dereference the nodes yet, you can use getString to get the unique ids and use the SessionInterface::getNodeByIdentifier as all referenced nodes are referenciable and thus must have a uuid. If its a PATH property, you will need the node of this property and use getNodes to get the nodes with relative or absolute path.
Type | Description |
---|---|
\PHPCR\NodeInterface | array | the referenced Node, or an array of Nodes for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if this property cannot be converted to a referring type (REFERENCE, WEAKREFERENCE or PATH) or if this property is a referring type but is currently part of the frozen state of a version in version storage. |
\PHPCR\ItemNotFoundException | If this property is of type PATH or WEAKREFERENCE and no target node accessible by the current Session exists in this workspace. Note that this applies even if the property is a PATH and a property exists at the specified location. To dereference to a target property (as opposed to a target node), the method PropertyInterface::getProperty() is used. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getParent() : \PHPCR\NodeInterface
Type | Description |
---|---|
\PHPCR\NodeInterface | The parent of this Item. |
Exception | Description |
---|---|
\PHPCR\ItemNotFoundException | if this Item is the root node of a workspace. |
\PHPCR\AccessDeniedException | if the current session does not have sufficient access to retrieve the parent of this item. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getPath() : string
Returns the normalized absolute path to this item.
Inherited from: \PHPCR\ItemInterface::getPath()Type | Description |
---|---|
string | the normalized absolute path of this Item. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getProperty() : \PHPCR\PropertyInterface | array
Gets the property the property refers to by its type.
If this property is of type PATH (or convertible to this type) this method returns the Property to which this property refers. If this property contains a relative path, it is interpreted relative to the parent node of this property. Therefore, when resolving such a relative path, the segment "." refers to the parent node itself, ".." to the parent of the parent node and "foo" to a sibling property of this property or this property itself.
For example, if this property is located at /a/b/c and it has a value of "../d" then this method will return the property at /a/d if such exists.
Type | Description |
---|---|
\PHPCR\PropertyInterface | array | the referenced property, or an array of properties for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if this property cannot be converted to a PATH or if this property is a referring type but is currently part of the frozen state of a version in version storage. |
\PHPCR\ItemNotFoundException | If no property accessible by the current Session exists in this workspace at the specified path. Note that this applies even if a node exists at the specified location. To dereference to a target node, the method PropertyInterface::getNode() is used. |
\PHPCR\RepositoryException | if another error occurs |
- Api
getSession() : \PHPCR\SessionInterface
Returns the Session through which this Item was acquired.
Inherited from: \PHPCR\ItemInterface::getSession()Type | Description |
---|---|
\PHPCR\SessionInterface | the Session through which this Item was acquired. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getString() : string | array
Returns a String representation of the value of this property.
Type | Description |
---|---|
string | array | A string representation of the value of this property, or an array of string for multi-valued properties. |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if conversion to a String is not possible |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getType() : integer
Returns the type of this Property.
Following property types are available:
- PropertyType::STRING
- PropertyType::BINARY
- PropertyType::DATE
- PropertyType::DOUBLE
- PropertyType::LONG
- PropertyType::BOOLEAN
- PropertyType::NAME
- PropertyType::PATH
- PropertyType::REFERENCE
- PropertyType::WEAKREFERENCE
- PropertyType::URI
The type returned is that which was set at property creation. Note that for some property p, the type returned by $p->getType() will differ from the type returned by $p->getDefinition()->getRequiredType() only in the case where the latter returns UNDEFINED. The type of a property instance is never UNDEFINED (it must always have some actual type).
Type | Description |
---|---|
integer | The numerical representation of a property type. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs |
- Api
- See
- \PHPCR\PropertyType
getValue() : mixed
Get the value in format default for the PropertyType of this property.
In case of a (WEAK)REFERENCE, the node is dereferenced and returned. For all other cases including PATH, the value is returned as is. If you want to dereference a PATH to a property or node, you need to explicitly call getNode() resp. getProperty().
PHPCR Note: We dropped the Value interface as its unnecessary with weak typing.
Type | Description |
---|---|
mixed | value of this property, or array in case of multi-value. |
isModified() : boolean
Indicates if the current item has been modified.
Inherited from: \PHPCR\ItemInterface::isModified()Returns true if this Item has been saved but has subsequently been modified through the current session and therefore the state of this item as recorded in the session differs from the state of this item as saved. Within a transaction, isModified on an Item may return false (because the Item has been saved since the modification) even if the modification in question is not in persistent storage (because the transaction has not yet been committed).
Note that in read-only implementations, this method will always return false.
Type | Description |
---|---|
boolean | true if this item is modified; false otherwise. |
- Api
isMultiple() : boolean
Determines if the current property is multi-valued.
Returns true if this property is multi-valued and false if this property is single-valued.
Type | Description |
---|---|
boolean | true if this property is multi-valued; false otherwise. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
isNew() : boolean
Returns true if this is a new item, meaning that it exists only in transient storage on the Session and has not yet been saved. Within a transaction, isNew on an Item may return false (because the item has been saved) even if that Item is not in persistent storage (because the transaction has not yet been committed).
Note that if an item returns true on isNew, then by definition is parent will return true on isModified.
Note that in read-only implementations, this method will always return false.
Type | Description |
---|---|
boolean | true if this item is new; false otherwise. |
- Api
isNode() : boolean
Indicates whether this Item is a Node or a Property.
Inherited from: \PHPCR\ItemInterface::isNode()Returns true if this Item is a Node; Returns false if this Item is a Property.
Type | Description |
---|---|
boolean | true if this Item is a Node, false if it is a Property. |
- Api
isSame(\PHPCR\ItemInterface $otherItem) : boolean
Determines if this Item object represents the same actual workspace item as the object otherItem.
Inherited from: \PHPCR\ItemInterface::isSame()Two Item objects represent the same workspace item if all the following are true:
- Both objects were acquired through Session objects that were created by the same Repository object.
- Both objects were acquired through Session objects bound to the same repository workspace.
- The objects are either both Node objects or both Property objects.
- If they are Node objects, they have the same identifier.
- If they are Property objects they have identical names and isSame() is true of their parent nodes.
This method does not compare the states of the two items. For example, if two Item objects representing the same actual workspace item have been retrieved through two different sessions and one has been modified, then this method will still return true when comparing these two objects. Note that if two Item objects representing the same workspace item are retrieved through the same session they will always reflect the same state.
Name | Type | Description |
---|---|---|
$otherItem | \PHPCR\ItemInterface | the Item object to be tested for identity with this Item. |
Type | Description |
---|---|
boolean | true if this Item object and otherItem represent the same actual repository item; false otherwise. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
remove() : void
To persist a removal, a save must be performed that includes the (former) parent of the removed item within its scope.
If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node. In other words, a removal compacts the array of same-name siblings and causes the minimal re-numbering required to maintain the original order but leave no gaps in the numbering.
Exception | Description |
---|---|
\PHPCR\Version\VersionException | if the parent node of this item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until save. |
\PHPCR\Lock\LockException | if a lock prevents the removal of this item and this implementation performs this validation immediately instead of waiting until save. |
\PHPCR\NodeType\ConstraintViolationException | if removing the specified item would violate a node type or implementation-specific constraint and this implementation performs this validation immediately instead of waiting until save. |
\PHPCR\AccessDeniedException | if this item or an item in its subgraph is currently the target of a REFERENCE property located in this workspace but outside this item's subgraph and the current Session does not have read access to that REFERENCE property or if the current Session does not have sufficient privileges to remove the item. |
\PHPCR\RepositoryException | if another error occurs. |
revert() : void
Discard all pending changes on this item and its children.
Inherited from: \PHPCR\ItemInterface::revert()This method discards all pending changes currently recorded in this
Session
that apply to this Item or any of its child nodes and properties and returns these items to reflect the current saved state. Outside a transaction this state is simply the current state of persistent storage. Within a transaction, this state will reflect persistent storage as modified by changes that have been saved but not yet committed.
Exception | Description |
---|---|
\PHPCR\InvalidItemStateException | if this Item object
represents a workspace item that has been removed (either by this
session or another). |
\PHPCR\RepositoryException | if another error occurs. |
- Since
- JCR 2.1
setValue(mixed $value, integer $type = null) : void
Sets the value of this property to the value.
If the type parameter is present and this implementation supports dynamic re-binding of properties, this property changes its type. First, a conversion of value into that type is attempted with PropertyType::convertType() and if there is no ValueFormatException, the property type changes to the new type. If the node type does not allow the requested type, a ConstraintViolationException is thrown. If the implementation does not support dynamic re-binding, an UnsupportedRepositoryException is thrown if the type parameter is present and different from the current type.
If no explicit type is given, then the type is derived from the value. (First value in case of multi-valuedproperty.) If the node type allows the type of the parameter, this property changes its type to the type of the value. Otherwise, a conversion of the value into the required type is attempted with PropertyType::convertType()
If value is of type PropertyInterface, the value of the property is copied into this property. (If type is set, the property value is converted into this type, otherwise the type of the property is used as in the case of no explicit type). This can be used to copy a binary from one property into another without getting the stream. The implemenation should take care to detect the case and copy the binary data directly in the backend for optimal performance.
The type detection follows PropertyType::determineType. Thus, passing a Node object without an explicit type (REFERENCE or WEAKREFERENCE) will create a REFERENCE property. If the specified node is not referenceable, a ValueFormatException is thrown.
To create a PATH property with a reference to an other property, you can call setValue with the return value of getPath called on the other property and the PATH type constant. Passing the property itself and the PATH type will convert the value of the property to a path.
When assigning a stream resource to write a binary property, the client application must leave the stream alone afterwards. The PHPCR implementation is responsible for closing it after saving.
This method is a session-write and therefore requires a
save
to dispatch the change.
If value is an array: If this property is not multi-valued then a ValueFormatException is thrown immediately.
PHPCR Note: The Java API defines this method with multiple differing signatures. PHPCR Note: Because we removed the Value interface, this method replaces ValueFactory::createValue.
Name | Type | Description |
---|---|---|
$value | mixed | The value to set |
$type | integer | Type request for the property, optional. Must be a constant from PropertyType |
Exception | Description |
---|---|
\PHPCR\ValueFormatException | if the type or format of the specified value is incompatible with the type of this property. |
\PHPCR\Version\VersionException | if this property belongs to a node that is read-only due to a checked-in node and this implementation performs this validation immediately. |
\PHPCR\Lock\LockException | if a lock prevents the setting of the value and this implementation performs this validation immediately. |
\PHPCR\NodeType\ConstraintViolationException | if the change would violate a node-type or other constraint and this implementation performs this validation immediately. |
\PHPCR\UnsupportedRepositoryOperationException | if the type parameter is set and different from the current type and this implementation does not support dynamic re-binding |
\InvalidArgumentException | if the specified DateTime value cannot be expressed in the ISO 8601-based format defined in the JCR 2.0 specification and the implementation does not support dates incompatible with that format. |
\PHPCR\RepositoryException | if another error occurs. |
- Api