layoutTempstoreRepository = $layout_tempstore_repository; $this->classResolver = $class_resolver; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('layout_builder.tempstore_repository'), $container->get('class_resolver') ); } /** * Adds the new section. * * @param \Drupal\layout_builder\SectionStorageInterface $section_storage * The section storage. * @param int $delta * The delta of the section to splice. * @param string $plugin_id * The plugin ID of the layout to add. * * @return \Symfony\Component\HttpFoundation\Response * The controller response. */ public function build(SectionStorageInterface $section_storage, $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()); } } }