diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index b6ffef722d..ea3e727e37 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -162,24 +162,17 @@ public function __unset($property_name) { /** * {@inheritdoc} */ - public function isComputed(){ + public function isComputed() { return $this instanceof FieldItemListComputedInterface; } /** * {@inheritdoc} */ - public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL) { - parent::__construct($definition, $name, $parent); - } - - /** - * {@inheritdoc - */ - public function getComputedValues(){ + public function setComputedValues() { $this->list = $this->computeValues(); $errors = $this->validate()->getIterator(); - if($errors->current()){ + if ($errors->current()) { throw new FieldException($errors->current()->getMessage()); } } diff --git a/core/lib/Drupal/Core/Field/FieldItemListComputedInterface.php b/core/lib/Drupal/Core/Field/FieldItemListComputedInterface.php index 98b364add2..cb8cd21f13 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListComputedInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListComputedInterface.php @@ -13,15 +13,8 @@ * This will populate the field item list with computed values. * * @return \Drupal\Core\TypedData\TypedDataInterface[] + * An array containing the field item values. */ public function computeValues(); - /** - * Determines if the field item List is computed. - * - * @return boolean - * TRUE if the field item list is computed. - */ - public function isComputed(); - } diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php index c350432e21..562d8457c8 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -125,6 +125,19 @@ public function __isset($property_name); public function __unset($property_name); /** + * Determines if the field item List is computed. + * + * @return bool + * TRUE if the field item list is computed. + */ + public function isComputed(); + + /** + * Populate the computed list with values. + */ + public function setComputedValues(); + + /** * Defines custom presave behavior for field values. * * This method is called during the process of saving an entity, just before diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 80b5d4a46c..d939de027c 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -202,9 +202,9 @@ public function getPropertyInstance(TypedDataInterface $object, $property_name, $property->setValue($value, FALSE); } elseif ($property instanceof FieldItemListComputedInterface) { - // populate the computed list with values as there are no initial values + // Populate the computed list with values as there are no initial values // to set. - $property->getComputedValues(); + $property->setComputedValues(); } return $property; }