protected function Paragraph::getNestedSummary

Returns summary items for nested paragraphs.

Parameters

string $field_name: Field definition id for paragraph.

array $options: (optional) An associative array of additional options. See \Drupal\paragraphs\ParagraphInterface::getSummary() for all of the available options.

Return value

array List of content summary items for nested elements.

1 call to Paragraph::getNestedSummary()
Paragraph::getSummaryItems in paragraphs/src/Entity/Paragraph.php
Returns the summary items of the Paragraph.

File

paragraphs/src/Entity/Paragraph.php, line 693

Class

Paragraph
Defines the Paragraph entity.

Namespace

Drupal\paragraphs\Entity

Code

protected function getNestedSummary($field_name, array $options) {
  $summary_content = [];
  if ($options['depth_limit'] >= 0) {
    foreach ($this
      ->get($field_name) as $item) {
      $entity = $item->entity;
      if ($entity instanceof ParagraphInterface) {

        // Switch to the entity translation in the current context if exists.
        $entity = \Drupal::service('entity.repository')
          ->getTranslationFromContext($entity, $this->activeLangcode);
        $content_summary_items = $entity
          ->getSummaryItems($options)['content'];
        $summary_content = array_merge($summary_content, array_values($content_summary_items));
        $this->summaryCount++;
      }
    }
  }
  return $summary_content;
}