You are here

public function ParagraphBlocksPanelsIpeBaseManager::hookPanelsIpeBlocksAlter in Paragraph blocks 8

Removes unused paragraphs and update the panels title from the paragraph.

Parameters

array $blocks: The blocks.

See also

hook_panels_ipe_blocks_alter()

File

src/ParagraphBlocksPanelsIpeBaseManager.php, line 80

Class

ParagraphBlocksPanelsIpeBaseManager
Handles panels IPE hooks to rename paragraph blocks.

Namespace

Drupal\paragraph_blocks

Code

public function hookPanelsIpeBlocksAlter(array &$blocks) {

  // Loop through all of the blocks.
  foreach ($blocks as $delta => $block) {
    $title = $this
      ->getTitle($block['plugin_id']);
    if ($title === FALSE) {

      // Remove the block if there is no paragraph data for the delta.
      unset($blocks[$delta]);
    }
    elseif ($title !== NULL) {

      // Replace the title.
      $blocks[$delta]['label'] = $title;
    }
  }
}