RemoveBlockForm.php in Drupal 10
File
core/modules/layout_builder/src/Form/RemoveBlockForm.php
View source
<?php
namespace Drupal\layout_builder\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\layout_builder\SectionStorageInterface;
class RemoveBlockForm extends LayoutRebuildConfirmFormBase {
protected $region;
protected $uuid;
public function getQuestion() {
$label = $this->sectionStorage
->getSection($this->delta)
->getComponent($this->uuid)
->getPlugin()
->label();
return $this
->t('Are you sure you want to remove the %label block?', [
'%label' => $label,
]);
}
public function getConfirmText() {
return $this
->t('Remove');
}
public function getFormId() {
return 'layout_builder_remove_block';
}
public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL, $delta = NULL, $region = NULL, $uuid = NULL) {
$this->region = $region;
$this->uuid = $uuid;
return parent::buildForm($form, $form_state, $section_storage, $delta);
}
protected function handleSectionStorage(SectionStorageInterface $section_storage, FormStateInterface $form_state) {
$section_storage
->getSection($this->delta)
->removeComponent($this->uuid);
}
}