protected function LayoutParagraphsRendererService::getParentEntity in Layout Paragraphs 2.0.x
Returns the parent entity for a given paragraph.
Parameters
\Drupal\paragraphs\Entity\Paragraph $paragraph: The paragraph.
Return value
\Drupal\Core\Entity\Entity The entity.
1 call to LayoutParagraphsRendererService::getParentEntity()
- LayoutParagraphsRendererService::renderLayoutSection in src/
LayoutParagraphsRendererService.php - Renders a single Layout Paragraph Section for the provided paragraph.
File
- src/
LayoutParagraphsRendererService.php, line 118
Class
- LayoutParagraphsRendererService
- Class definition for a layout paragraphs service.
Namespace
Drupal\layout_paragraphsCode
protected function getParentEntity(Paragraph $paragraph) {
$type = $paragraph
->get('parent_type')->value;
$id = $paragraph
->get('parent_id')->value;
if (!isset(static::$parentEntities["{$type}:{$id}"])) {
static::$parentEntities["{$type}:{$id}"] = $paragraph
->getParentEntity();
}
return static::$parentEntities["{$type}:{$id}"];
}