interface ComplexDataInterface
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/ComplexDataInterface.php \Drupal\Core\TypedData\ComplexDataInterface
- 8.9.x core/lib/Drupal/Core/TypedData/ComplexDataInterface.php \Drupal\Core\TypedData\ComplexDataInterface
- 10 core/lib/Drupal/Core/TypedData/ComplexDataInterface.php \Drupal\Core\TypedData\ComplexDataInterface
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.
Hierarchy
- interface \Drupal\Core\TypedData\TypedDataInterface
- interface \Drupal\Core\TypedData\TraversableTypedDataInterface extends \Drupal\Core\TypedData\TypedDataInterface \Drupal\Core\TypedData\Traversable
- interface \Drupal\Core\TypedData\ComplexDataInterface extends \Drupal\Core\TypedData\TraversableTypedDataInterface
- interface \Drupal\Core\TypedData\TraversableTypedDataInterface extends \Drupal\Core\TypedData\TypedDataInterface \Drupal\Core\TypedData\Traversable
Expanded class hierarchy of ComplexDataInterface
All classes that implement ComplexDataInterface
See also
\Drupal\Core\TypedData\ComplexDataDefinitionInterface
Related topics
15 files declare their use of ComplexDataInterface
- AllowedValuesConstraintValidator.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ AllowedValuesConstraintValidator.php - ArrayElement.php in core/
lib/ Drupal/ Core/ Config/ Schema/ ArrayElement.php - ComplexDataConstraintValidator.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ ComplexDataConstraintValidator.php - ComplexDataNormalizer.php in core/
modules/ serialization/ src/ Normalizer/ ComplexDataNormalizer.php - ComplexDataNormalizerTest.php in core/
modules/ serialization/ tests/ src/ Unit/ Normalizer/ ComplexDataNormalizerTest.php
File
-
core/
lib/ Drupal/ Core/ TypedData/ ComplexDataInterface.php, line 21
Namespace
Drupal\Core\TypedDataView source
interface ComplexDataInterface extends TraversableTypedDataInterface {
/**
* Gets the data definition.
*
* @return \Drupal\Core\TypedData\ComplexDataDefinitionInterface
* The data definition object describing the complex data.
*/
public function getDataDefinition();
/**
* Gets a property object.
*
* @param $property_name
* The name of the property to get; e.g., 'title' or 'name'.
*
* @return \Drupal\Core\TypedData\TypedDataInterface
* The property object.
*
* @throws \InvalidArgumentException
* If an invalid property name is given.
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
* If the complex data structure is unset and no property can be created.
*/
public function get($property_name);
/**
* Sets a property value.
*
* @param $property_name
* The name of the property to set; e.g., 'title' or 'name'.
* @param $value
* The value to set, or NULL to unset the property.
* @param bool $notify
* (optional) Whether to notify the parent object of the change. Defaults to
* TRUE. If the update stems from a parent object, set it to FALSE to avoid
* being notified again.
*
* @return $this
*
* @throws \InvalidArgumentException
* If the specified property does not exist.
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
* If the complex data structure is unset and no property can be set.
*/
public function set($property_name, $value, $notify = TRUE);
/**
* Gets an array of property objects.
*
* @param bool $include_computed
* If set to TRUE, computed properties are included. Defaults to FALSE.
*
* @return \Drupal\Core\TypedData\TypedDataInterface[]
* An array of property objects implementing the TypedDataInterface, keyed
* by property name.
*
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
* If the complex data structure is unset and no property can be created.
*/
public function getProperties($include_computed = FALSE);
/**
* Returns an array of all property values.
*
* Gets an array of plain property values including all not-computed
* properties.
*
* @return array
* An array of property values, keyed by property name.
*
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
* If the complex data structure is unset and no property can be created.
*/
public function toArray();
/**
* Determines whether the data structure is empty.
*
* @return bool
* TRUE if the data structure is empty, FALSE otherwise.
*/
public function isEmpty();
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ComplexDataInterface::get | public | function | Gets a property object. | 2 | |
ComplexDataInterface::getDataDefinition | public | function | Gets the data definition. | Overrides TypedDataInterface::getDataDefinition | |
ComplexDataInterface::getProperties | public | function | Gets an array of property objects. | 3 | |
ComplexDataInterface::isEmpty | public | function | Determines whether the data structure is empty. | 2 | |
ComplexDataInterface::set | public | function | Sets a property value. | 3 | |
ComplexDataInterface::toArray | public | function | Returns an array of all property values. | 2 | |
TraversableTypedDataInterface::onChange | public | function | React to changes to a child property or item. | 4 | |
TypedDataInterface::applyDefaultValue | public | function | Applies the default value. | 1 | |
TypedDataInterface::createInstance | public static | function | Constructs a TypedData object given its definition and context. | 1 | |
TypedDataInterface::getConstraints | public | function | Gets a list of validation constraints. | 1 | |
TypedDataInterface::getName | public | function | Returns the name of a property or item. | 1 | |
TypedDataInterface::getParent | public | function | Returns the parent data structure; i.e. either complex data or a list. | 1 | |
TypedDataInterface::getPropertyPath | public | function | Returns the property path of the data. | 1 | |
TypedDataInterface::getRoot | public | function | Returns the root of the typed data tree. | 1 | |
TypedDataInterface::getString | public | function | Returns a string representation of the data. | 1 | |
TypedDataInterface::getValue | public | function | Gets the data value. | 1 | |
TypedDataInterface::setContext | public | function | Sets the context of a property or item via a context aware parent. | 1 | |
TypedDataInterface::setValue | public | function | Sets the data value. | 1 | |
TypedDataInterface::validate | public | function | Validates the currently set data value. | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.