0002497e9480daf61512bb3ce83895da8a6809b7
[yaffs-website] / web / core / lib / Drupal / Core / TypedData / ComplexDataDefinitionBase.php
1 <?php
2
3 namespace Drupal\Core\TypedData;
4
5 /**
6  * Base class for complex data definitions.
7  */
8 abstract class ComplexDataDefinitionBase extends DataDefinition implements ComplexDataDefinitionInterface {
9
10   /**
11    * An array of data definitions.
12    *
13    * @var \Drupal\Core\TypedData\DataDefinitionInterface[]
14    */
15   protected $propertyDefinitions;
16
17   /**
18    * {@inheritdoc}
19    */
20   abstract public function getPropertyDefinitions();
21
22   /**
23    * {@inheritdoc}
24    */
25   public function getPropertyDefinition($name) {
26     $definitions = $this->getPropertyDefinitions();
27     if (isset($definitions[$name])) {
28       return $definitions[$name];
29     }
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function getMainPropertyName() {
36     return NULL;
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function __sleep() {
43     // Do not serialize the cached property definitions.
44     $vars = get_object_vars($this);
45     unset($vars['propertyDefinitions'], $vars['typedDataManager']);
46     return array_keys($vars);
47   }
48
49 }