diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php index b586bd6..a59f7d1 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php @@ -64,7 +64,8 @@ public function getTarget() { if (!isset($this->target) && isset($this->id)) { // If we have a valid reference, return the entity object which is typed // data itself. - $this->target = entity_load($this->definition['constraints']['EntityType'], $this->id); + $constraints = $this->definition->getConstraints(); + $this->target = entity_load($constraints['EntityType'], $this->id); } return $this->target; } @@ -101,7 +102,7 @@ public function setValue($value, $notify = TRUE) { if (!isset($value) || $value instanceof EntityInterface) { $this->target = $value; } - elseif (!is_scalar($value) || empty($this->definition['constraints']['EntityType'])) { + elseif (!is_scalar($value) || (($constraints = $this->definition->getConstraints()) && empty($constraints['EntityType']))) { throw new \InvalidArgumentException('Value is not a valid entity.'); } else { diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php index 12bec01..dd97479 100644 --- a/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -69,7 +69,7 @@ public function getPluginId() { * {@inheritdoc} */ public function getPluginDefinition() { - return \Drupal::typedData()->getDefinition($this->definition['type']); + return \Drupal::typedData()->getDefinition($this->definition->getDataType()); } /** diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 8205ea1..1045697 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -189,6 +189,9 @@ public function getInstance(array $options) { public function getPropertyInstance(TypedDataInterface $object, $property_name, $value = NULL) { $definition = $object->getRoot()->getDefinition(); $key = $definition->getDataType(); + if ($definition instanceof ListDefinition) { + $key .= ':' . $definition->getItemDefinition()->getDataType(); + } if ($settings = $definition->getSettings()) { $key .= ':' . implode(',', $settings); } diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php index 897a146..ef42c2f 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php @@ -95,8 +95,9 @@ public function onChange($property_name) { // Unset processed properties that are affected by the change. foreach ($this->getPropertyDefinitions() as $property => $definition) { - if (isset($definition['class']) && ($definition['class'] == '\Drupal\text\TextProcessed')) { - if ($property_name == 'format' || (isset($definition['settings']['text source']) && $definition['settings']['text source'] == $property_name)) { + if ($definition->getClass() == '\Drupal\text\TextProcessed') { + $settings = $definition->getSettings(); + if ($property_name == 'format' || (isset($settings['text source']) && $settings['text source'] == $property_name)) { $this->set($property, NULL, FALSE); } } diff --git a/core/modules/text/lib/Drupal/text/TextProcessed.php b/core/modules/text/lib/Drupal/text/TextProcessed.php index 0f69102..22a0772 100644 --- a/core/modules/text/lib/Drupal/text/TextProcessed.php +++ b/core/modules/text/lib/Drupal/text/TextProcessed.php @@ -32,7 +32,8 @@ class TextProcessed extends TypedData { public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL) { parent::__construct($definition, $name, $parent); - if (!isset($definition['settings']['text source'])) { + $settings = $definition->getSettings(); + if (!isset($settings['text source'])) { throw new \InvalidArgumentException("The definition's 'source' key has to specify the name of the text property to be processed."); } } @@ -46,7 +47,8 @@ public function getValue($langcode = NULL) { } $item = $this->getParent(); - $text = $item->{($this->definition['settings']['text source'])}; + $settings = $this->definition->getSettings(); + $text = $item->{($settings['text source'])}; // Avoid running check_markup() or check_plain() on empty strings. if (!isset($text) || $text === '') {