summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/TypedData/ComplexDataDefinitionBase.php
blob: 0002497e9480daf61512bb3ce83895da8a6809b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

namespace Drupal\Core\TypedData;

/**
 * Base class for complex data definitions.
 */
abstract class ComplexDataDefinitionBase extends DataDefinition implements ComplexDataDefinitionInterface {

  /**
   * An array of data definitions.
   *
   * @var \Drupal\Core\TypedData\DataDefinitionInterface[]
   */
  protected $propertyDefinitions;

  /**
   * {@inheritdoc}
   */
  abstract public function getPropertyDefinitions();

  /**
   * {@inheritdoc}
   */
  public function getPropertyDefinition($name) {
    $definitions = $this->getPropertyDefinitions();
    if (isset($definitions[$name])) {
      return $definitions[$name];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getMainPropertyName() {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function __sleep() {
    // Do not serialize the cached property definitions.
    $vars = get_object_vars($this);
    unset($vars['propertyDefinitions'], $vars['typedDataManager']);
    return array_keys($vars);
  }

}