You are here

protected function FileUpload::getUploadValidators in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::getUploadValidators()

Returns all applicable upload validators.

Return value

array[] A set of argument arrays for each upload validator, keyed by the upload validator's function name.

1 call to FileUpload::getUploadValidators()
FileUpload::getForm in src/Plugin/EntityBrowser/Widget/FileUpload.php

File

src/Plugin/EntityBrowser/Widget/FileUpload.php, line 77

Class

FileUpload
An Entity Browser widget for creating media entities from uploaded files.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

protected function getUploadValidators() {
  $validators = $this->configuration['upload_validators'];

  // If the widget context didn't specify any file extension validation, add
  // it as the first validator, allowing it to accept only file extensions
  // associated with existing media bundles.
  if (empty($validators['file_validate_extensions'])) {
    return array_merge([
      'file_validate_extensions' => [
        implode(' ', $this
          ->getAllowedFileExtensions()),
      ],
    ], $validators);
  }
  return $validators;
}