public function MediaSelection::validateReferenceableNewEntities in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/src/Plugin/EntityReferenceSelection/MediaSelection.php \Drupal\media\Plugin\EntityReferenceSelection\MediaSelection::validateReferenceableNewEntities()
- 9 core/modules/media/src/Plugin/EntityReferenceSelection/MediaSelection.php \Drupal\media\Plugin\EntityReferenceSelection\MediaSelection::validateReferenceableNewEntities()
File
- core/
modules/ media/ src/ Plugin/ EntityReferenceSelection/ MediaSelection.php, line 50
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;
}