You are here

public function DashboardDeleteBlockForm::submitForm in Draggable dashboard 8.2

Parameters

array $form:

\Drupal\Core\Form\FormStateInterface $form_state:

Throws

\Drupal\Core\Entity\EntityStorageException

Overrides FormInterface::submitForm

File

src/Form/DashboardDeleteBlockForm.php, line 103

Class

DashboardDeleteBlockForm
Class DashboardDeleteBlockForm

Namespace

Drupal\draggable_dashboard\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $block_id = $form_state
    ->getValue('block_id');
  $blocks = $this->dashboard
    ->get('blocks');
  if (isset($blocks[$block_id])) {
    unset($blocks[$block_id]);
  }
  $this->dashboard
    ->set('blocks', $blocks)
    ->save();
  $form_state
    ->setRedirect('entity.dashboard_entity.edit_form', [
    'dashboard_entity' => $this->dashboard
      ->id(),
  ]);
}