ComplexDataInterface
interface ComplexDataInterface implements TraversableTypedDataInterface (View source)
Interface for complex data; i.e. data containing named and typed properties.
The name of a property has to be a valid PHP variable name, starting with an alphabetic character.
This is implemented by entities as well as by field item classes of entities.
When implementing this interface which extends Traversable, make sure to list IteratorAggregate or Iterator before this interface in the implements clause.
Methods
Constructs a TypedData object given its definition and context.
Gets the data definition.
Validates the currently set data value.
Returns the parent data structure; i.e. either complex data or a list.
Returns the root of the typed data tree.
Sets the context of a property or item via a context aware parent.
Gets a property object.
Sets a property value.
Gets an array of property objects.
Returns an array of all property values.
Determines whether the data structure is empty.
Details
static
createInstance(DataDefinitionInterface $definition, string|null $name = NULL, TraversableTypedDataInterface $parent = NULL)
Constructs a TypedData object given its definition and context.
DataDefinitionInterface
getDataDefinition()
Gets the data definition.
mixed
getValue()
Gets the data value.
setValue(mixed|null $value, bool $notify = TRUE)
Sets the data value.
string
getString()
Returns a string representation of the data.
array
getConstraints()
Gets a list of validation constraints.
ConstraintViolationListInterface
validate()
Validates the currently set data value.
$this
applyDefaultValue(bool $notify = TRUE)
Applies the default value.
string|int|null
getName()
Returns the name of a property or item.
TraversableTypedDataInterface|null
getParent()
Returns the parent data structure; i.e. either complex data or a list.
TraversableTypedDataInterface
getRoot()
Returns the root of the typed data tree.
Returns the root data for a tree of typed data objects; e.g. for an entity field item the root of the tree is its parent entity object.
string
getPropertyPath()
Returns the property path of the data.
The trail of property names relative to the root of the typed data tree, separated by dots; e.g. 'field_text.0.format'.
setContext(string|null $name = NULL, TraversableTypedDataInterface $parent = NULL)
Sets the context of a property or item via a context aware parent.
This method is supposed to be called by the factory only.
onChange($name)
React to changes to a child property or item.
Note that this is invoked after any changes have been applied.
TypedDataInterface
get($property_name)
Gets a property object.
$this
set($property_name, $value, bool $notify = TRUE)
Sets a property value.
TypedDataInterface[]
getProperties(bool $include_computed = FALSE)
Gets an array of property objects.
array
toArray()
Returns an array of all property values.
Gets an array of plain property values including all not-computed properties.
bool
isEmpty()
Determines whether the data structure is empty.