ComplexDataDefinitionBase.php 1002 B

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