{% import '@lib/di.twig' as di %} '']; return $options; } /** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state): void { $form['example'] = [ '#type' => 'textfield', '#title' => $this->t('Example'), '#default_value' => $this->options['example'], ]; } {% endif %} /** * {@inheritdoc} * * @todo Make sure the return type-hint matches the argument type. */ public function getArgument(): int { // @DCG // Here is the place where you should create a default argument for the // contextual filter. The source of this argument depends on your needs. // For example, the argument can be extracted from the URL or fetched from // some fields of the currently viewed entity. $argument = 123; return $argument; } /** * {@inheritdoc} */ public function getCacheMaxAge(): int { return Cache::PERMANENT; } /** * {@inheritdoc} */ public function getCacheContexts(): array { // @todo Use 'url.path' or 'url.query_args:%key' contexts if the argument // comes from URL. return []; } }