class FilefieldSourcesPreRenderCallback in FileField Sources 8
Hierarchy
- class \Drupal\filefield_sources\FilefieldSourcesPreRenderCallback implements TrustedCallbackInterface
Expanded class hierarchy of FilefieldSourcesPreRenderCallback
File
- src/
FilefieldSourcesPreRenderCallback.php, line 8
Namespace
Drupal\filefield_sourcesView source
class FilefieldSourcesPreRenderCallback implements TrustedCallbackInterface {
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return [
'preRender',
];
}
/**
* #pre_render callback: hide sources if a file is currently uploaded.
*/
public static function preRender($element) {
// If we already have a file, we don't want to show the upload controls.
if (!empty($element['#value']['fids'])) {
foreach (Element::children($element) as $key) {
if (!empty($element[$key]['#filefield_source'])) {
$element[$key]['#access'] = FALSE;
}
}
}
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FilefieldSourcesPreRenderCallback:: |
public static | function | #pre_render callback: hide sources if a file is currently uploaded. | |
FilefieldSourcesPreRenderCallback:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |