You are here

protected function DashboardConfigureBlockForm::init in Draggable dashboard 8.2

Initialize the form state and the entity before the first form build.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: Form state object.

\Drupal\draggable_dashboard\Entity\DashboardEntityInterface $dashboard_entity: Dashboard object.

string $block_id: Id of the block to configure.

Overrides DashboardBlockFormBase::init

1 call to DashboardConfigureBlockForm::init()
DashboardConfigureBlockForm::buildForm in src/Form/DashboardConfigureBlockForm.php
Form constructor.

File

src/Form/DashboardConfigureBlockForm.php, line 39

Class

DashboardConfigureBlockForm
Class DashboardConfigureBlockForm

Namespace

Drupal\draggable_dashboard\Form

Code

protected function init(FormStateInterface $form_state, DashboardEntityInterface $dashboard_entity, $block_id = '') {
  parent::init($form_state, $dashboard_entity);
  $blocks = $dashboard_entity
    ->get('blocks');
  if (!empty($blocks[$block_id])) {
    $this->block = $blocks[$block_id];
  }
  else {
    $this->block = [
      'settings' => [
        'id' => 'broken',
      ],
    ];
  }
  $this->block_id = $block_id;
}