class RemoveSectionForm

Same name and namespace in other branches
  1. 11.x core/modules/layout_builder/src/Form/RemoveSectionForm.php \Drupal\layout_builder\Form\RemoveSectionForm
  2. 10 core/modules/layout_builder/src/Form/RemoveSectionForm.php \Drupal\layout_builder\Form\RemoveSectionForm
  3. 8.9.x core/modules/layout_builder/src/Form/RemoveSectionForm.php \Drupal\layout_builder\Form\RemoveSectionForm

Provides a form to confirm the removal of a section.

@internal Form classes are internal.

Hierarchy

Expanded class hierarchy of RemoveSectionForm

1 string reference to 'RemoveSectionForm'
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/Form/RemoveSectionForm.php, line 14

Namespace

Drupal\layout_builder\Form
View source
class RemoveSectionForm extends LayoutRebuildConfirmFormBase {
  
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'layout_builder_remove_section';
  }
  
  /**
   * {@inheritdoc}
   */
  public function getQuestion() {
    $configuration = $this->sectionStorage
      ->getSection($this->delta)
      ->getLayoutSettings();
    // Layouts may choose to use a class that might not have a label
    // configuration.
    if (!empty($configuration['label'])) {
      return $this->t('Are you sure you want to remove @section?', [
        '@section' => $configuration['label'],
      ]);
    }
    return $this->t('Are you sure you want to remove section @section?', [
      '@section' => $this->delta + 1,
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getConfirmText() {
    return $this->t('Remove');
  }
  
  /**
   * {@inheritdoc}
   */
  protected function handleSectionStorage(SectionStorageInterface $section_storage, FormStateInterface $form_state) {
    $section_storage->removeSection($this->delta);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.