FilefieldSourcesPreRenderCallback.php in FileField Sources 8
File
src/FilefieldSourcesPreRenderCallback.php
View source
<?php
namespace Drupal\filefield_sources;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\Render\Element;
class FilefieldSourcesPreRenderCallback implements TrustedCallbackInterface {
public static function trustedCallbacks() {
return [
'preRender',
];
}
public static function preRender($element) {
if (!empty($element['#value']['fids'])) {
foreach (Element::children($element) as $key) {
if (!empty($element[$key]['#filefield_source'])) {
$element[$key]['#access'] = FALSE;
}
}
}
return $element;
}
}