You are here

protected function ParagraphDeleteForm::findParentFieldItem in Paragraphs table 8

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 ParagraphDeleteForm::findParentFieldItem()
ParagraphDeleteForm::submitForm in src/Form/ParagraphDeleteForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

src/Form/ParagraphDeleteForm.php, line 95

Class

ParagraphDeleteForm
Provides a form for deleting a paragraph from a node.

Namespace

Drupal\paragraphs_table\Form

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;
}