RemoveSectionForm.php in Drupal 10
File
core/modules/layout_builder/src/Form/RemoveSectionForm.php
View source
<?php
namespace Drupal\layout_builder\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\layout_builder\SectionStorageInterface;
class RemoveSectionForm extends LayoutRebuildConfirmFormBase {
public function getFormId() {
return 'layout_builder_remove_section';
}
public function getQuestion() {
$configuration = $this->sectionStorage
->getSection($this->delta)
->getLayoutSettings();
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,
]);
}
public function getConfirmText() {
return $this
->t('Remove');
}
protected function handleSectionStorage(SectionStorageInterface $section_storage, FormStateInterface $form_state) {
$section_storage
->removeSection($this->delta);
}
}