multipleCapable = FALSE; $this->termStorage = $entity_manager->getStorage('taxonomy_term'); } /** * {@inheritdoc} */ protected function defineOptions() { $options = parent::defineOptions(); $options['transform'] = ['default' => FALSE]; return $options; } /** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['transform'] = [ '#type' => 'checkbox', '#title' => $this->t('Transform dashes in URL to spaces in term name filter values'), '#default_value' => $this->options['transform'], ]; } /** * {@inheritdoc} */ public function validateArgument($argument) { if ($this->options['transform']) { $argument = str_replace('-', ' ', $argument); } $terms = $this->termStorage->loadByProperties(['name' => $argument]); if (!$terms) { // Returned empty array no terms with the name. return FALSE; } // Not knowing which term will be used if more than one is returned check // each one. foreach ($terms as $term) { if (!$this->validateEntity($term)) { return FALSE; } } return TRUE; } }