public function MoveBlockController::build in Layout Builder Restrictions 8.2
Moves a block to another region.
Parameters
\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.
int $delta_from: The delta of the original section.
int $delta_to: The delta of the destination section.
string $region_to: The new region for this block.
string $block_uuid: The UUID for this block.
string|null $preceding_block_uuid: (optional) If provided, the UUID of the block to insert this block after.
Return value
\Drupal\Core\Ajax\AjaxResponse An AJAX response.
Overrides MoveBlockController::build
File
- src/
Controller/ MoveBlockController.php, line 40
Class
- MoveBlockController
- Defines a controller to move a block.
Namespace
Drupal\layout_builder_restrictions\ControllerCode
public function build(SectionStorageInterface $section_storage, $delta_from, $delta_to, $region_to, $block_uuid, $preceding_block_uuid = NULL) {
// Retrieve defined Layout Builder Restrictions plugins.
$layout_builder_restrictions_manager = \Drupal::service('plugin.manager.layout_builder_restriction');
$restriction_plugins = $layout_builder_restrictions_manager
->getSortedPlugins();
foreach (array_keys($restriction_plugins) as $id) {
$plugin = $layout_builder_restrictions_manager
->createInstance($id);
$block_status = $plugin
->blockAllowedinContext($section_storage, $delta_from, $delta_to, $region_to, $block_uuid, $preceding_block_uuid);
if ($block_status !== TRUE) {
return $this
->restrictLayout($section_storage, $block_status);
}
}
return parent::build($section_storage, $delta_from, $delta_to, $region_to, $block_uuid, $preceding_block_uuid);
}