3 namespace Drupal\Core\Field;
6 * Defines a item list class for map fields.
8 class MapFieldItemList extends FieldItemList {
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.
20 if ($count1 !== $count2) {
21 // The number of items is different so they do not have the same values.
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();
31 return $value1 == $value2;