public function FileSelection::validateReferenceableNewEntities in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php \Drupal\file\Plugin\EntityReferenceSelection\FileSelection::validateReferenceableNewEntities()
Validates which newly created entities can be referenced.
This method should replicate the logic implemented by \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::validateReferenceableEntities(), but applied to newly created entities that have not been saved yet.
Parameters
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities to check.
Return value
\Drupal\Core\Entity\EntityInterface[] The incoming $entities parameter, filtered for valid entities. Array keys are preserved.
Overrides DefaultSelection::validateReferenceableNewEntities
File
- core/
modules/ file/ src/ Plugin/ EntityReferenceSelection/ FileSelection.php, line 58 - Contains \Drupal\file\Plugin\EntityReferenceSelection\FileSelection.
Class
- FileSelection
- Provides specific access control for the file entity type.
Namespace
Drupal\file\Plugin\EntityReferenceSelectionCode
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;
}