Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Field / FieldItemList.php
index a1a1ebdb9ebb12c02e3789471d6de1becb1c79ac..d3eb205a022515f526a7ef5b3edfdff2d898bcc8 100644 (file)
@@ -7,6 +7,7 @@ use Drupal\Core\Entity\FieldableEntityInterface;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\TypedData\DataDefinitionInterface;
 use Drupal\Core\TypedData\Plugin\DataType\ItemList;
 
 /**
@@ -94,18 +95,6 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
     return $this;
   }
 
-  /**
-   * {@inheritdoc}
-   * @todo Revisit the need when all entity types are converted to NG entities.
-   */
-  public function getValue($include_computed = FALSE) {
-    $values = [];
-    foreach ($this->list as $delta => $item) {
-      $values[$delta] = $item->getValue($include_computed);
-    }
-    return $values;
-  }
-
   /**
    * {@inheritdoc}
    */
@@ -259,7 +248,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
    */
   public function generateSampleItems($count = 1) {
     $field_definition = $this->getFieldDefinition();
-    $field_type_class = \Drupal::service('plugin.manager.field.field_type')->getPluginClass($field_definition->getType());
+    $field_type_class = $field_definition->getItemDefinition()->getClass();
     for ($delta = 0; $delta < $count; $delta++) {
       $values[$delta] = $field_type_class::generateSampleValue($field_definition);
     }
@@ -378,7 +367,6 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
    * {@inheritdoc}
    */
   public function equals(FieldItemListInterface $list_to_compare) {
-    $columns = $this->getFieldDefinition()->getFieldStorageDefinition()->getColumns();
     $count1 = count($this);
     $count2 = count($list_to_compare);
     if ($count1 === 0 && $count2 === 0) {
@@ -396,9 +384,13 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
     }
     // If the values are not equal ensure a consistent order of field item
     // properties and remove properties which will not be saved.
-    $callback = function (&$value) use ($columns) {
+    $property_definitions = $this->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinitions();
+    $non_computed_properties = array_filter($property_definitions, function (DataDefinitionInterface $property) {
+      return !$property->isComputed();
+    });
+    $callback = function (&$value) use ($non_computed_properties) {
       if (is_array($value)) {
-        $value = array_intersect_key($value, $columns);
+        $value = array_intersect_key($value, $non_computed_properties);
         ksort($value);
       }
     };
@@ -408,4 +400,11 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
     return $value1 == $value2;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function hasAffectingChanges(FieldItemListInterface $original_items, $langcode) {
+    return !$this->equals($original_items);
+  }
+
 }