You are here

protected function elFinderVolumeDrupal::CheckExtension in elFinder file manager 8.2

Same name and namespace in other branches
  1. 6.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::CheckExtension()
  2. 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::CheckExtension()
  3. 7.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::CheckExtension()

Check if file extension is allowed

@author Alexey Sukhotin

Parameters

stdClass $file file object:

Return value

array

4 calls to elFinderVolumeDrupal::CheckExtension()
elFinderVolumeDrupal::_copy in src/Controller/elFinderVolumeDrupal.php
Copy file into another file
elFinderVolumeDrupal::_mkfile in src/Controller/elFinderVolumeDrupal.php
Create file
elFinderVolumeDrupal::_move in src/Controller/elFinderVolumeDrupal.php
Move file into another parent dir
elFinderVolumeDrupal::_save in src/Controller/elFinderVolumeDrupal.php
Create new file and write into it from file pointer. Return new file path or false on error.

File

src/Controller/elFinderVolumeDrupal.php, line 60
elFinder driver for Drupal filesystem.

Class

elFinderVolumeDrupal
@file

Code

protected function CheckExtension($file) {
  $allowed_extensions = \Drupal::config('elfinder.settings')
    ->get('filesystem.allowed_extensions');
  if (!empty($allowed_extensions)) {
    $errors = file_validate_extensions($file, $allowed_extensions);
    if (!empty($errors)) {
      $this
        ->setError(implode(' ', $errors));
      return FALSE;
    }
  }
  return TRUE;
}