You are here

public function PanelsIPEPageController::getBlockPluginForm in Panels 8.4

Same name and namespace in other branches
  1. 8.3 panels_ipe/src/Controller/PanelsIPEPageController.php \Drupal\panels_ipe\Controller\PanelsIPEPageController::getBlockPluginForm()

Drupal AJAX compatible route for rendering a given Block Plugin's form.

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 $plugin_id: The requested Block Plugin ID.

string $block_uuid: The Block UUID, if this is an existing Block.

Return value

Response

1 string reference to 'PanelsIPEPageController::getBlockPluginForm'
panels_ipe.routing.yml in panels_ipe/panels_ipe.routing.yml
panels_ipe/panels_ipe.routing.yml

File

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

Class

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

Namespace

Drupal\panels_ipe\Controller

Code

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

  // Get the configuration in the block plugin definition.
  $definitions = $this->blockManager
    ->getDefinitionsForContexts($panels_display
    ->getContexts());

  // Check if the block plugin is defined.
  if (!isset($definitions[$plugin_id])) {
    throw new NotFoundHttpException();
  }

  // Build a Block Plugin configuration form.
  $form = $this
    ->formBuilder()
    ->getForm('Drupal\\panels_ipe\\Form\\PanelsIPEBlockPluginForm', $plugin_id, $panels_display, $block_uuid);

  // Return the rendered form as a proper Drupal AJAX response.
  $response = new AjaxResponse();
  $command = new AppendCommand('.ipe-block-form', $form);
  $response
    ->addCommand($command);
  return $response;
}