You are here

public function EntityReferenceRevisionsFieldDiffBuilder::getEntitiesToDiff in Entity Reference Revisions 8

Builds an array of entities.

This method is responsible for transforming a FieldItemListInterface object into an array of entities. The resulted array of entities is then used when parsing the entity to get a clean array of fields that will be compared.

Parameters

\Drupal\Core\Field\FieldItemListInterface $field_items: Represents an entity field.

Return value

\Drupal\Core\Entity\EntityInterface[] An array of entities to be compared. If an empty array is returned it means that a field is either empty or no properties need to be compared for that field.

Overrides FieldReferenceInterface::getEntitiesToDiff

File

src/Plugin/diff/Field/EntityReferenceRevisionsFieldDiffBuilder.php, line 48

Class

EntityReferenceRevisionsFieldDiffBuilder
This plugins offers the possibility to compare ERR fields.

Namespace

Drupal\entity_reference_revisions\Plugin\diff\Field

Code

public function getEntitiesToDiff(FieldItemListInterface $field_items) {

  /** @var \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem $field_item */
  $entities = [];
  foreach ($field_items as $field_key => $field_item) {
    if (!$field_item
      ->isEmpty() && $field_item->entity) {
      $entities[$field_key] = $field_item->entity;
    }
  }
  return $entities;
}