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