FileUrlSelection.php in File URL 2.0.x
File
src/Plugin/EntityReferenceSelection/FileUrlSelection.php
View source
<?php
namespace Drupal\file_url\Plugin\EntityReferenceSelection;
use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
class FileUrlSelection extends DefaultSelection {
public function validateReferenceableEntities(array $ids) {
$file_handler = \Drupal::service('file_url.handler');
$found = [];
foreach ($ids as $id) {
$file = $file_handler::urlToFile($id);
if ($file_handler
->isRemote($file)) {
$uri = $file
->getFileUri();
}
else {
$uri = $file_handler::fileToUrl($file);
}
if (in_array($uri, $ids)) {
$found[] = $uri;
}
}
return $found;
}
}
Classes
Name |
Description |
FileUrlSelection |
Default plugin implementation of the Entity Reference Selection plugin. |