public function AddSectionController::build in Drupal 9
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Controller/AddSectionController.php \Drupal\layout_builder\Controller\AddSectionController::build()
Adds the new section.
Parameters
\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.
int $delta: The delta of the section to splice.
string $plugin_id: The plugin ID of the layout to add.
Return value
\Symfony\Component\HttpFoundation\Response The controller response.
1 string reference to 'AddSectionController::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/ AddSectionController.php, line 63
Class
- AddSectionController
- Defines a controller to add a new section.
Namespace
Drupal\layout_builder\ControllerCode
public function build(SectionStorageInterface $section_storage, int $delta, $plugin_id) {
$section_storage
->insertSection($delta, new Section($plugin_id));
$this->layoutTempstoreRepository
->set($section_storage);
if ($this
->isAjax()) {
return $this
->rebuildAndClose($section_storage);
}
else {
$url = $section_storage
->getLayoutBuilderUrl();
return new RedirectResponse($url
->setAbsolute()
->toString());
}
}