Returns summary items for nested paragraphs.
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.
array List of content summary items for nested elements.
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
->language()
->getId());
$content_summary_items = $entity
->getSummaryItems($options)['content'];
$summary_content = array_merge($summary_content, array_values($content_summary_items));
$this->summaryCount++;
}
}
}
return $summary_content;
}