public function ParagraphLineageInspector::getParentField in Paragraphs Edit 8.2
Gets the field the paragraph is referenced from.
Parameters
\Drupal\paragraphs\ParagraphInterface $paragraph: Paragraph data.
Return value
\Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList|null Parent field.
2 calls to ParagraphLineageInspector::getParentField()
- ParagraphLineageInspector::getLineageString in src/
ParagraphLineageInspector.php - Builds a string representation of a paragraph's lineage.
- ParagraphLineageInspector::getParentFieldItem in src/
ParagraphLineageInspector.php - Gets the field item the paragraph is referenced from.
File
- src/
ParagraphLineageInspector.php, line 39
Class
- ParagraphLineageInspector
- ParagraphLineageInspector class.
Namespace
Drupal\paragraphs_editCode
public function getParentField(ParagraphInterface $paragraph) {
$parent = $paragraph
->getParentEntity();
if (!$parent) {
return NULL;
}
return $parent
->get($paragraph
->get('parent_field_name')->value);
}