trait LayoutRebuildTrait
Same name in other branches
- 8.9.x core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php \Drupal\layout_builder\Controller\LayoutRebuildTrait
- 10 core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php \Drupal\layout_builder\Controller\LayoutRebuildTrait
- 11.x core/modules/layout_builder/src/Controller/LayoutRebuildTrait.php \Drupal\layout_builder\Controller\LayoutRebuildTrait
Provides AJAX responses to rebuild the Layout Builder.
Hierarchy
- trait \Drupal\layout_builder\Controller\LayoutRebuildTrait
4 files declare their use of LayoutRebuildTrait
- ConfigureBlockFormBase.php in core/
modules/ layout_builder/ src/ Form/ ConfigureBlockFormBase.php - ConfigureSectionForm.php in core/
modules/ layout_builder/ src/ Form/ ConfigureSectionForm.php - LayoutRebuildConfirmFormBase.php in core/
modules/ layout_builder/ src/ Form/ LayoutRebuildConfirmFormBase.php - MoveBlockForm.php in core/
modules/ layout_builder/ src/ Form/ MoveBlockForm.php
File
-
core/
modules/ layout_builder/ src/ Controller/ LayoutRebuildTrait.php, line 13
Namespace
Drupal\layout_builder\ControllerView source
trait LayoutRebuildTrait {
/**
* Rebuilds the layout.
*
* @param \Drupal\layout_builder\SectionStorageInterface $section_storage
* The section storage.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* An AJAX response to either rebuild the layout and close the dialog, or
* reload the page.
*/
protected function rebuildAndClose(SectionStorageInterface $section_storage) {
$response = $this->rebuildLayout($section_storage);
$response->addCommand(new CloseDialogCommand('#drupal-off-canvas'));
return $response;
}
/**
* Rebuilds the layout.
*
* @param \Drupal\layout_builder\SectionStorageInterface $section_storage
* The section storage.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* An AJAX response to either rebuild the layout and close the dialog, or
* reload the page.
*/
protected function rebuildLayout(SectionStorageInterface $section_storage) {
$response = new AjaxResponse();
$layout = [
'#type' => 'layout_builder',
'#section_storage' => $section_storage,
];
$response->addCommand(new ReplaceCommand('#layout-builder', $layout));
return $response;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
LayoutRebuildTrait::rebuildAndClose | protected | function | Rebuilds the layout. |
LayoutRebuildTrait::rebuildLayout | protected | function | Rebuilds the layout. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.