public function TermName::validateArgument in Drupal 10
Same name and namespace in other branches
- 8 core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php \Drupal\taxonomy\Plugin\views\argument_validator\TermName::validateArgument()
- 9 core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php \Drupal\taxonomy\Plugin\views\argument_validator\TermName::validateArgument()
Overrides Entity::validateArgument
File
- core/
modules/ taxonomy/ src/ Plugin/ views/ argument_validator/ TermName.php, line 64
Class
- TermName
- Validates whether a term name is a valid term argument.
Namespace
Drupal\taxonomy\Plugin\views\argument_validatorCode
public function validateArgument($argument) {
if ($this->options['transform']) {
$argument = str_replace('-', ' ', $argument);
$this->argument->argument = $argument;
}
// If bundles is set then restrict the loaded terms to the given bundles.
if (!empty($this->options['bundles'])) {
$terms = $this->termStorage
->loadByProperties([
'name' => $argument,
'vid' => $this->options['bundles'],
]);
}
else {
$terms = $this->termStorage
->loadByProperties([
'name' => $argument,
]);
}
// $terms are already bundle tested but we need to test access control.
foreach ($terms as $term) {
if ($this
->validateEntity($term)) {
return TRUE;
}
}
return FALSE;
}