You are here

function geysir_get_non_paragraph_parent in Geysir 8

Gets the first parent that is not a paragraph.

Parameters

Drupal\Core\Entity\EntityInterface $entity:

Return value

Drupal\Core\Entity\EntityInterface $entity

1 call to geysir_get_non_paragraph_parent()
geysir_preprocess_field in ./geysir.module
Implements hook_preprocess_HOOK().

File

./geysir.module, line 125
Geysir module file.

Code

function geysir_get_non_paragraph_parent(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() != 'paragraph') {
    return $entity;
  }
  else {

    /** @var Drupal\paragraphs\Entity\Paragraph $entity */
    return geysir_get_non_paragraph_parent($entity
      ->getParentEntity());
  }
}