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