You are here

public function MoveBlockController::restrictLayout in Layout Builder Restrictions 8.2

Called if a block move fails layout_builder_restriction validation.

See also

\Drupal\layout_builder\Controller\MoveBlockController::move()

1 call to MoveBlockController::restrictLayout()
MoveBlockController::build in src/Controller/MoveBlockController.php
Moves a block to another region.

File

src/Controller/MoveBlockController.php, line 24

Class

MoveBlockController
Defines a controller to move a block.

Namespace

Drupal\layout_builder_restrictions\Controller

Code

public function restrictLayout(SectionStorageInterface $section_storage, $error) {
  $response = new AjaxResponse();
  $layout = [
    '#type' => 'layout_builder',
    '#section_storage' => $section_storage,
  ];

  // Revert layout and present error dialog.
  $response
    ->addCommand(new ReplaceCommand('#layout-builder', $layout));
  $response
    ->addCommand(new OpenDialogCommand("#layout-builder-restrictions-error", "Content cannot be placed.", $error));
  return $response;
}