You are here

public function ParagraphBlocksEntity::getSummary in Paragraph blocks 8

Same name and namespace in other branches
  1. 8.2 src/Entity/ParagraphBlocksEntity.php \Drupal\paragraph_blocks\Entity\ParagraphBlocksEntity::getSummary()
  2. 3.x src/Entity/ParagraphBlocksEntity.php \Drupal\paragraph_blocks\Entity\ParagraphBlocksEntity::getSummary()

Returns a short summary for the Paragraph.

Parameters

array $options: (optional) Array of additional options, with the following elements:

  • 'show_behavior_summary': Whether the summary should contain the behavior settings. Defaults to TRUE to show behavior settings in the summary.
  • 'depth_limit': Depth limit of how many nested paragraph summaries are allowed. Defaults to 1 to show nested paragraphs only on top level.

Return value

string The template based summary.

Overrides Paragraph::getSummary

File

src/Entity/ParagraphBlocksEntity.php, line 18

Class

ParagraphBlocksEntity
Extend the Paragraph entity.

Namespace

Drupal\paragraph_blocks\Entity

Code

public function getSummary(array $options = []) {

  // Get any field with title in the name.
  $value = $this->admin_title
    ->getValue();
  foreach ($this
    ->getFieldDefinitions() as $field_name => $field_definition) {
    if (strpos($field_name, 'title') !== FALSE) {
      $text = $this
        ->getTextSummary($field_name, $field_definition);
      if (!empty($text)) {
        return $text;
      }
    }
  }
  return parent::getSummary($options);
}