Security update for Core, with self-updated composer
[yaffs-website] / web / core / lib / Drupal / Core / Field / MapFieldItemList.php
1 <?php
2
3 namespace Drupal\Core\Field;
4
5 /**
6  * Defines a item list class for map fields.
7  */
8 class MapFieldItemList extends FieldItemList {
9
10   /**
11    * {@inheritdoc}
12    */
13   public function equals(FieldItemListInterface $list_to_compare) {
14     $count1 = count($this);
15     $count2 = count($list_to_compare);
16     if ($count1 === 0 && $count2 === 0) {
17       // Both are empty we can safely assume that it did not change.
18       return TRUE;
19     }
20     if ($count1 !== $count2) {
21       // The number of items is different so they do not have the same values.
22       return FALSE;
23     }
24
25     // The map field type does not have any property defined (because they are
26     // dynamic), so the only way to evaluate the equality for it is to rely
27     // solely on its values.
28     $value1 = $this->getValue();
29     $value2 = $list_to_compare->getValue();
30
31     return $value1 == $value2;
32   }
33
34 }