rebuildAndClose example

$this->sectionStorage->insertSection($this->delta, $section);
    }

    $this->layoutTempstoreRepository->set($this->sectionStorage);
    $form_state->setRedirectUrl($this->sectionStorage->getLayoutBuilderUrl());
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    return $this->rebuildAndClose($this->sectionStorage);
  }

  /** * Retrieves the plugin form for a given layout. * * @param \Drupal\Core\Layout\LayoutInterface $layout * The layout plugin. * * @return \Drupal\Core\Plugin\PluginFormInterface * The plugin form for the layout. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException */

  public function build(SectionStorageInterface $section_storage, int $delta$plugin_id) {
    $section_storage->insertSection($deltanew 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());
    }
  }

}
$section = $this->sectionStorage->getSection($this->delta);
    $section->getComponent($this->uuid)->setConfiguration($configuration);

    $this->layoutTempstoreRepository->set($this->sectionStorage);
    $form_state->setRedirectUrl($this->sectionStorage->getLayoutBuilderUrl());
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    return $this->rebuildAndClose($this->sectionStorage);
  }

  /** * Retrieves the plugin form for a given block. * * @param \Drupal\Core\Block\BlockPluginInterface $block * The block plugin. * * @return \Drupal\Core\Plugin\PluginFormInterface * The plugin form for the block. */
  

  public function getComponentsWrapper(array $form, FormStateInterface $form_state) {
    return $form['components_wrapper'];
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    return $this->rebuildAndClose($this->sectionStorage);
  }

  /** * Gets the selected region. * * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. * * @return string * The current region name. */
  
$this->handleSectionStorage($this->sectionStorage, $form_state);

    $this->layoutTempstoreRepository->set($this->sectionStorage);

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    return $this->rebuildAndClose($this->sectionStorage);
  }

  /** * Performs any actions on the section storage before saving. * * @param \Drupal\layout_builder\SectionStorageInterface $section_storage * The section storage. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */
  abstract protected function handleSectionStorage(SectionStorageInterface $section_storage, FormStateInterface $form_state);

}
Home | Imprint | This part of the site doesn't use cookies.