You are here

protected function ParagraphLineageInspector::findParentFieldItem in Paragraphs Edit 8.2

Finds the field item the paragraph is referenced from.

Parameters

\Drupal\paragraphs\ParagraphInterface $paragraph: Paragraph data.

\Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $field: Field item.

Return value

\Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem|null Referenced field item.

1 call to ParagraphLineageInspector::findParentFieldItem()
ParagraphLineageInspector::getParentFieldItem in src/ParagraphLineageInspector.php
Gets the field item the paragraph is referenced from.

File

src/ParagraphLineageInspector.php, line 79

Class

ParagraphLineageInspector
ParagraphLineageInspector class.

Namespace

Drupal\paragraphs_edit

Code

protected function findParentFieldItem(ParagraphInterface $paragraph, EntityReferenceRevisionsFieldItemList $field) {
  $paragraph_id = $paragraph
    ->id();
  $paragraph_revision_id = $paragraph
    ->getRevisionId();
  foreach ($field as $item) {
    if ($item->target_id == $paragraph_id && $item->target_revision_id == $paragraph_revision_id) {
      return $item;
    }
  }
  return NULL;
}