Chris@14: layoutTempstoreRepository = $layout_tempstore_repository; Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public static function create(ContainerInterface $container) { Chris@14: return new static( Chris@18: $container->get('layout_builder.tempstore_repository') Chris@14: ); Chris@14: } Chris@14: Chris@14: /** Chris@14: * Moves a block to another region. Chris@14: * Chris@14: * @param \Drupal\layout_builder\SectionStorageInterface $section_storage Chris@14: * The section storage. Chris@14: * @param int $delta_from Chris@14: * The delta of the original section. Chris@14: * @param int $delta_to Chris@14: * The delta of the destination section. Chris@14: * @param string $region_to Chris@14: * The new region for this block. Chris@14: * @param string $block_uuid Chris@14: * The UUID for this block. Chris@14: * @param string|null $preceding_block_uuid Chris@14: * (optional) If provided, the UUID of the block to insert this block after. Chris@14: * Chris@14: * @return \Drupal\Core\Ajax\AjaxResponse Chris@14: * An AJAX response. Chris@14: */ Chris@14: public function build(SectionStorageInterface $section_storage, $delta_from, $delta_to, $region_to, $block_uuid, $preceding_block_uuid = NULL) { Chris@14: $section = $section_storage->getSection($delta_from); Chris@14: Chris@14: $component = $section->getComponent($block_uuid); Chris@14: $section->removeComponent($block_uuid); Chris@14: Chris@14: // If the block is moving from one section to another, update the original Chris@14: // section and load the new one. Chris@14: if ($delta_from !== $delta_to) { Chris@14: $section = $section_storage->getSection($delta_to); Chris@14: } Chris@14: Chris@14: // If a preceding block was specified, insert after that. Otherwise add the Chris@14: // block to the front. Chris@14: $component->setRegion($region_to); Chris@14: if (isset($preceding_block_uuid)) { Chris@14: $section->insertAfterComponent($preceding_block_uuid, $component); Chris@14: } Chris@14: else { Chris@14: $section->insertComponent(0, $component); Chris@14: } Chris@14: Chris@14: $this->layoutTempstoreRepository->set($section_storage); Chris@14: return $this->rebuildLayout($section_storage); Chris@14: } Chris@14: Chris@14: }