routeMatch = $route_match; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, $plugin_definition, $container->get('current_route_match') ); } /** * {@inheritdoc} */ protected function defineOptions() { $options = parent::defineOptions(); $options['example_option'] = ['default' => '']; return $options; } /** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['example_option'] = [ '#type' => 'textfield', '#title' => t('Some example option'), '#default_value' => $this->options['example_option'], ]; } /** * {@inheritdoc} */ public function getArgument() { // @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, you can extract the value from the URL or fetch it from // some fields of the current viewed entity. // For now let's use example option as an argument. $argument = $this->options['example_option']; return $argument; } /** * {@inheritdoc} */ public function getCacheMaxAge() { return Cache::PERMANENT; } /** * {@inheritdoc} */ public function getCacheContexts() { return ['url']; } }