{% import '@lib/di.twig' as di %} $this->t('Hello world!'), ]; } /** * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state): array { $form['example'] = [ '#type' => 'textarea', '#title' => $this->t('Example'), '#default_value' => $this->configuration['example'], ]; return $form; } /** * {@inheritdoc} */ public function blockSubmit($form, FormStateInterface $form_state): void { $this->configuration['example'] = $form_state->getValue('example'); } {% endif %} /** * {@inheritdoc} */ public function build(): array { $build['content'] = [ '#markup' => $this->t('It works!'), ]; return $build; } {% if access %} /** * {@inheritdoc} */ protected function blockAccess(AccountInterface $account): AccessResult { // @todo Evaluate the access condition here. return AccessResult::allowedIf(TRUE); } {% endif %} }