You are here

public function PanelsIPEPageController::getBlockModelData in Panels 8.4

Gets a single Block from the current Panels Display as data. Uses TempStore.

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.

string $block_uuid: The Block UUID.

Return value

\Symfony\Component\HttpFoundation\JsonResponse

1 call to PanelsIPEPageController::getBlockModelData()
PanelsIPEPageController::getBlock in panels_ipe/src/Controller/PanelsIPEPageController.php
Gets a single Block from the current Panels Display as JSON.

File

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

Class

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

Namespace

Drupal\panels_ipe\Controller

Code

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

  /** @var \Drupal\Core\Block\BlockBase $block_instance */
  $block_instance = $panels_display
    ->getBlock($block_uuid);
  $block_config = $block_instance
    ->getConfiguration();

  // Assemble data required for our App.
  $build = $this
    ->buildBlockInstance($block_instance, $panels_display);

  // Bubble Block attributes to fix bugs with the Quickedit and Contextual
  // modules.
  $this
    ->bubbleBlockAttributes($build);

  // Add our data attribute for the Backbone app.
  $build['#attributes']['data-block-id'] = $block_uuid;
  $plugin_definition = $block_instance
    ->getPluginDefinition();
  $block_model = [
    'uuid' => $block_uuid,
    'label' => $block_instance
      ->label(),
    'id' => $block_instance
      ->getPluginId(),
    'region' => $block_config['region'],
    'provider' => $block_config['provider'],
    'plugin_id' => $plugin_definition['id'],
    'html' => $this->renderer
      ->render($build),
  ];
  return $block_model;
}