'']; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['title'] = [ '#title' => t('New title'), '#type' => 'textfield', '#required' => TRUE, '#default_value' => $this->configuration['title'], ]; return $form; } /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['title'] = $form_state->getValue('title'); } {% endif %} /** * {@inheritdoc} */ public function access($node, AccountInterface $account = NULL, $return_as_object = FALSE) { /** @var \Drupal\node\NodeInterface $node */ $access = $node->access('update', $account, TRUE) ->andIf($node->title->access('edit', $account, TRUE)); return $return_as_object ? $access : $access->isAllowed(); } /** * {@inheritdoc} */ public function execute($node = NULL) { /** @var \Drupal\node\NodeInterface $node */ {% if configurable %} $node->setTitle($this->configuration['title'])->save(); {% else %} $node->setTitle(t('New title'))->save(); {% endif %} } }