{% import '@lib/di.twig' as di %} '']; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state): array { $form['example'] = [ '#type' => 'textfield', '#title' => $this->t('Example'), '#default_value' => $this->configuration['example'], ]; return $form; } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state): void { $this->configuration['example'] = $form_state->getValue('example'); } {% endif %} /** * {@inheritdoc} */ public function access($entity, AccountInterface $account = NULL, $return_as_object = FALSE): AccessResultInterface|bool { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $access = $entity->access('update', $account, TRUE) ->andIf($entity->get('field_example')->access('edit', $account, TRUE)); return $return_as_object ? $access : $access->isAllowed(); } /** * {@inheritdoc} */ public function execute(ContentEntityInterface $entity = NULL): void { $entity->set('field_example', 'New value')->save(); } }