Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AddSectionController.php

function 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\Controller

Code

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());
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal