function TermSelection::validateReferenceableNewEntities
Same name in other branches
- 9 core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::validateReferenceableNewEntities()
- 8.9.x core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::validateReferenceableNewEntities()
- 11.x core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php \Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::validateReferenceableNewEntities()
Overrides DefaultSelection::validateReferenceableNewEntities
File
-
core/
modules/ taxonomy/ src/ Plugin/ EntityReferenceSelection/ TermSelection.php, line 130
Class
- TermSelection
- Provides specific access control for the taxonomy_term entity type.
Namespace
Drupal\taxonomy\Plugin\EntityReferenceSelectionCode
public function validateReferenceableNewEntities(array $entities) {
$entities = parent::validateReferenceableNewEntities($entities);
// Mirror the conditions checked in buildEntityQuery().
if (!$this->currentUser
->hasPermission('administer taxonomy')) {
$entities = array_filter($entities, function ($term) {
/** @var \Drupal\taxonomy\TermInterface $term */
return $term->isPublished();
});
}
return $entities;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.