function LayoutSectionItemList::equals

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

Overrides FieldItemList::equals

File

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

Class

LayoutSectionItemList
Defines an 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.