Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / TypedData / ComplexDataInterface.php
1 <?php
2
3 namespace Drupal\Core\TypedData;
4
5 /**
6  * Interface for complex data; i.e. data containing named and typed properties.
7  *
8  * The name of a property has to be a valid PHP variable name, starting with
9  * an alphabetic character.
10  *
11  * This is implemented by entities as well as by field item classes of
12  * entities.
13  *
14  * When implementing this interface which extends Traversable, make sure to list
15  * IteratorAggregate or Iterator before this interface in the implements clause.
16  *
17  * @see \Drupal\Core\TypedData\ComplexDataDefinitionInterface
18  *
19  * @ingroup typed_data
20  */
21 interface ComplexDataInterface extends TraversableTypedDataInterface {
22
23   /**
24    * Gets the data definition.
25    *
26    * @return \Drupal\Core\TypedData\ComplexDataDefinitionInterface
27    *   The data definition object describing the complex data.
28    */
29   public function getDataDefinition();
30
31   /**
32    * Gets a property object.
33    *
34    * @param $property_name
35    *   The name of the property to get; e.g., 'title' or 'name'.
36    *
37    * @return \Drupal\Core\TypedData\TypedDataInterface
38    *   The property object.
39    *
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.
44    */
45   public function get($property_name);
46
47   /**
48    * Sets a property value.
49    *
50    * @param $property_name
51    *   The name of the property to set; e.g., 'title' or 'name'.
52    * @param $value
53    *   The value to set, or NULL to unset the property.
54    * @param bool $notify
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.
58    *
59    * @return $this
60    *
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.
65    */
66   public function set($property_name, $value, $notify = TRUE);
67
68   /**
69    * Gets an array of property objects.
70    *
71    * @param bool $include_computed
72    *   If set to TRUE, computed properties are included. Defaults to FALSE.
73    *
74    * @return \Drupal\Core\TypedData\TypedDataInterface[]
75    *   An array of property objects implementing the TypedDataInterface, keyed
76    *   by property name.
77    *
78    * @throws \Drupal\Core\TypedData\Exception\MissingDataException
79    *   If the complex data structure is unset and no property can be created.
80    */
81   public function getProperties($include_computed = FALSE);
82
83   /**
84    * Returns an array of all property values.
85    *
86    * Gets an array of plain property values including all not-computed
87    * properties.
88    *
89    * @return array
90    *   An array of property values, keyed by property name.
91    *
92    * @throws \Drupal\Core\TypedData\Exception\MissingDataException
93    *   If the complex data structure is unset and no property can be created.
94    */
95   public function toArray();
96
97   /**
98    * Determines whether the data structure is empty.
99    *
100    * @return bool
101    *   TRUE if the data structure is empty, FALSE otherwise.
102    */
103   public function isEmpty();
104
105 }