You are here

public function LayoutSectionItemList::equals in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::equals()
  2. 10 core/modules/layout_builder/src/Field/LayoutSectionItemList.php \Drupal\layout_builder\Field\LayoutSectionItemList::equals()

Determines equality to another object implementing FieldItemListInterface.

This method is usually used by the storage to check for not computed value changes, which will be saved into the storage.

Parameters

\Drupal\Core\Field\FieldItemListInterface $list_to_compare: The field item list to compare to.

Return value

bool TRUE if the field item lists are equal, FALSE if not.

Overrides FieldItemList::equals

File

core/modules/layout_builder/src/Field/LayoutSectionItemList.php, line 84

Class

LayoutSectionItemList
Defines a item list class for layout section fields.

Namespace

Drupal\layout_builder\Field

Code

public function equals(FieldItemListInterface $list_to_compare) {
  if (!$list_to_compare instanceof LayoutSectionItemList) {
    return FALSE;
  }

  // Convert arrays of section objects to array values for comparison.
  $convert = function (LayoutSectionItemList $list) {
    return array_map(function (Section $section) {
      return $section
        ->toArray();
    }, $list
      ->getSections());
  };
  return $convert($this) === $convert($list_to_compare);
}