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