You are here

protected function ParagraphBlocksPanelsIpeBaseManager::getTitle in Paragraph blocks 8

Returns the plugin's paragraph title.

Parameters

string $plugin_id: The plugin id.

Return value

string The paragraph title.

2 calls to ParagraphBlocksPanelsIpeBaseManager::getTitle()
ParagraphBlocksPanelsIpeBaseManager::hookFormPanelsIpeBlockPluginFormAlter in src/ParagraphBlocksPanelsIpeBaseManager.php
Change the title on the add/edit form.
ParagraphBlocksPanelsIpeBaseManager::hookPanelsIpeBlocksAlter in src/ParagraphBlocksPanelsIpeBaseManager.php
Removes unused paragraphs and update the panels title from the paragraph.

File

src/ParagraphBlocksPanelsIpeBaseManager.php, line 104

Class

ParagraphBlocksPanelsIpeBaseManager
Handles panels IPE hooks to rename paragraph blocks.

Namespace

Drupal\paragraph_blocks

Code

protected function getTitle($plugin_id) {
  $plugin_parts = explode(':', $plugin_id);
  if (count($plugin_parts) < 4) {
    return NULL;
  }
  list($plugin_type_id, , $plugin_field_name, $plugin_field_delta) = $plugin_parts;
  if ($plugin_type_id != $this->pluginTypeId) {
    return NULL;
  }

  // Return if this plugin should be removed from the list.
  if (!$this->entity || $plugin_field_delta >= $this->entity
    ->get($plugin_field_name)
    ->count()) {
    return FALSE;
  }

  // Get the referenced paragraph.

  /** @var \Drupal\paragraphs\Entity\Paragraph $paragraph */
  $paragraph = $this->entity
    ->get($plugin_field_name)
    ->referencedEntities()[$plugin_field_delta];

  // Change the label to match admin_label from the referenced paragraph.
  return str_replace('@label', $paragraph
    ->getSummary(), $this->labelFormat);
}