You are here

public function PanelsIPEPageController::getBlockPluginsData in Panels 8.4

Gets a list of Block Plugins from the server as data.

Parameters

string $panels_storage_type: The id of the storage plugin.

string $panels_storage_id: The id within the storage plugin for the requested Panels display.

Return value

\Symfony\Component\HttpFoundation\JsonResponse

1 call to PanelsIPEPageController::getBlockPluginsData()
PanelsIPEPageController::getBlockPlugins in panels_ipe/src/Controller/PanelsIPEPageController.php
Gets a list of Block Plugins from the server as JSON.

File

panels_ipe/src/Controller/PanelsIPEPageController.php, line 320

Class

PanelsIPEPageController
Contains all JSON endpoints required for Panels IPE + Page Manager.

Namespace

Drupal\panels_ipe\Controller

Code

public function getBlockPluginsData($panels_storage_type, $panels_storage_id) {
  $panels_display = $this
    ->loadPanelsDisplay($panels_storage_type, $panels_storage_id);

  // Get block plugin definitions from the server.
  $definitions = $this->blockManager
    ->getDefinitionsForContexts($panels_display
    ->getContexts());

  // Assemble our relevant data.
  $blocks = [];
  foreach ($definitions as $plugin_id => $definition) {

    // Don't add broken Blocks.
    if ($plugin_id == 'broken') {
      continue;
    }
    $blocks[] = [
      'plugin_id' => $plugin_id,
      'label' => $definition['admin_label'],
      'category' => $definition['category'],
      'id' => $definition['id'],
      'provider' => $definition['provider'],
    ];
  }

  // Trigger hook_panels_ipe_blocks_alter(). Allows other modules to change
  // the list of blocks that are visible.
  \Drupal::moduleHandler()
    ->alter('panels_ipe_blocks', $blocks, $panels_display);

  // We need to re-index our return value, in case a hook unset a block.
  $blocks = array_values($blocks);
  return $blocks;
}