You are here

protected function FileUpload::getAllowedFileExtensions in Lightning Media 8.4

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

Returns all file extensions accepted by the allowed media types.

Return value

string[] The allowed file extensions.

1 call to FileUpload::getAllowedFileExtensions()
FileUpload::getUploadValidators in src/Plugin/EntityBrowser/Widget/FileUpload.php
Returns all applicable upload validators.

File

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

Class

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

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

protected function getAllowedFileExtensions() {
  $extensions = '';
  foreach ($this
    ->getAllowedTypes() as $media_type) {
    $extensions .= $media_type
      ->getSource()
      ->getSourceFieldDefinition($media_type)
      ->getSetting('file_extensions') . ' ';
  }
  $extensions = preg_split('/,?\\s+/', rtrim($extensions));
  return array_unique($extensions);
}