3 namespace Drupal\Core\TypedData;
6 * Interface for complex data; i.e. data containing named and typed properties.
8 * The name of a property has to be a valid PHP variable name, starting with
9 * an alphabetic character.
11 * This is implemented by entities as well as by field item classes of
14 * When implementing this interface which extends Traversable, make sure to list
15 * IteratorAggregate or Iterator before this interface in the implements clause.
17 * @see \Drupal\Core\TypedData\ComplexDataDefinitionInterface
21 interface ComplexDataInterface extends TraversableTypedDataInterface {
24 * Gets the data definition.
26 * @return \Drupal\Core\TypedData\ComplexDataDefinitionInterface
27 * The data definition object describing the complex data.
29 public function getDataDefinition();
32 * Gets a property object.
34 * @param $property_name
35 * The name of the property to get; e.g., 'title' or 'name'.
37 * @return \Drupal\Core\TypedData\TypedDataInterface
38 * The property object.
40 * @throws \InvalidArgumentException
41 * If an invalid property name is given.
42 * @throws \Drupal\Core\TypedData\Exception\MissingDataException
43 * If the complex data structure is unset and no property can be created.
45 public function get($property_name);
48 * Sets a property value.
50 * @param $property_name
51 * The name of the property to set; e.g., 'title' or 'name'.
53 * The value to set, or NULL to unset the property.
55 * (optional) Whether to notify the parent object of the change. Defaults to
56 * TRUE. If the update stems from a parent object, set it to FALSE to avoid
57 * being notified again.
61 * @throws \InvalidArgumentException
62 * If the specified property does not exist.
63 * @throws \Drupal\Core\TypedData\Exception\MissingDataException
64 * If the complex data structure is unset and no property can be set.
66 public function set($property_name, $value, $notify = TRUE);
69 * Gets an array of property objects.
71 * @param bool $include_computed
72 * If set to TRUE, computed properties are included. Defaults to FALSE.
74 * @return \Drupal\Core\TypedData\TypedDataInterface[]
75 * An array of property objects implementing the TypedDataInterface, keyed
78 * @throws \Drupal\Core\TypedData\Exception\MissingDataException
79 * If the complex data structure is unset and no property can be created.
81 public function getProperties($include_computed = FALSE);
84 * Returns an array of all property values.
86 * Gets an array of plain property values including all not-computed
90 * An array of property values, keyed by property name.
92 * @throws \Drupal\Core\TypedData\Exception\MissingDataException
93 * If the complex data structure is unset and no property can be created.
95 public function toArray();
98 * Determines whether the data structure is empty.
101 * TRUE if the data structure is empty, FALSE otherwise.
103 public function isEmpty();