function MoveBlockController::build
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.
1 string reference to 'MoveBlockController::build'
- layout_builder.routing.yml in core/
modules/ layout_builder/ layout_builder.routing.yml  - core/modules/layout_builder/layout_builder.routing.yml
 
File
- 
              core/
modules/ layout_builder/ src/ Controller/ MoveBlockController.php, line 65  
Class
- MoveBlockController
 - Defines a controller to move a block.
 
Namespace
Drupal\layout_builder\ControllerCode
public function build(SectionStorageInterface $section_storage, int $delta_from, int $delta_to, $region_to, $block_uuid, $preceding_block_uuid = NULL) {
  $section = $section_storage->getSection($delta_from);
  $component = $section->getComponent($block_uuid);
  $section->removeComponent($block_uuid);
  // If the block is moving from one section to another, update the original
  // section and load the new one.
  if ($delta_from !== $delta_to) {
    $section = $section_storage->getSection($delta_to);
  }
  // If a preceding block was specified, insert after that. Otherwise add the
  // block to the front.
  $component->setRegion($region_to);
  if (isset($preceding_block_uuid)) {
    $section->insertAfterComponent($preceding_block_uuid, $component);
  }
  else {
    $section->insertComponent(0, $component);
  }
  $this->layoutTempstoreRepository
    ->set($section_storage);
  return $this->rebuildLayout($section_storage);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.