You are here

public function FileSelection::validateReferenceableNewEntities in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php \Drupal\file\Plugin\EntityReferenceSelection\FileSelection::validateReferenceableNewEntities()
  2. 9 core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php \Drupal\file\Plugin\EntityReferenceSelection\FileSelection::validateReferenceableNewEntities()

File

core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php, line 54

Class

FileSelection
Provides specific access control for the file entity type.

Namespace

Drupal\file\Plugin\EntityReferenceSelection

Code

public function validateReferenceableNewEntities(array $entities) {
  $entities = parent::validateReferenceableNewEntities($entities);
  $entities = array_filter($entities, function ($file) {

    /** @var \Drupal\file\FileInterface $file */
    return $file
      ->isPermanent() || $file
      ->getOwnerId() === $this->currentUser
      ->id();
  });
  return $entities;
}