protected static function LibraryItem::buildLabel

Builds a label for the library item.

Parameters

\Drupal\paragraphs\ParagraphInterface $paragraph: The paragraph for which the label should be generated.

Return value

string

1 call to LibraryItem::buildLabel()
LibraryItem::createFromParagraph in paragraphs/modules/paragraphs_library/src/Entity/LibraryItem.php
Creates a library entity from a paragraph entity.

File

paragraphs/modules/paragraphs_library/src/Entity/LibraryItem.php, line 295

Class

LibraryItem
Defines the LibraryItem entity.

Namespace

Drupal\paragraphs_library\Entity

Code

protected static function buildLabel(ParagraphInterface $paragraph) {
  $summary = $paragraph
    ->getSummaryItems([
    'show_behavior_summary' => FALSE,
  ]);
  $summary = Unicode::truncate(implode(', ', $summary['content']), 50);
  return $paragraph
    ->getParagraphType()
    ->label() . ': ' . $summary;
}