public function Entity::validateArgument in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::validateArgument()
- 9 core/modules/views/src/Plugin/views/argument_validator/Entity.php \Drupal\views\Plugin\views\argument_validator\Entity::validateArgument()
2 methods override Entity::validateArgument()
- TermName::validateArgument in core/
modules/ taxonomy/ src/ Plugin/ views/ argument_validator/ TermName.php - UserName::validateArgument in core/
modules/ user/ src/ Plugin/ views/ argument_validator/ UserName.php
File
- core/
modules/ views/ src/ Plugin/ views/ argument_validator/ Entity.php, line 177
Class
- Entity
- Defines an argument validator plugin for each entity type.
Namespace
Drupal\views\Plugin\views\argument_validatorCode
public function validateArgument($argument) {
$entity_type = $this->definition['entity_type'];
if ($this->multipleCapable && $this->options['multiple']) {
// At this point only interested in individual IDs no matter what type,
// just splitting by the allowed delimiters.
$ids = array_filter(preg_split('/[,+ ]/', $argument));
}
elseif ($argument) {
$ids = [
$argument,
];
}
else {
return FALSE;
}
$entities = $this->entityTypeManager
->getStorage($entity_type)
->loadMultiple($ids);
// Validate each id => entity. If any fails break out and return false.
foreach ($ids as $id) {
// There is no entity for this ID.
if (!isset($entities[$id])) {
return FALSE;
}
if (!$this
->validateEntity($entities[$id])) {
return FALSE;
}
}
return TRUE;
}