You are here

class File in Feeds 8.3

Same name in this branch
  1. 8.3 src/Utility/File.php \Drupal\feeds\Utility\File
  2. 8.3 src/Feeds/Target/File.php \Drupal\feeds\Feeds\Target\File

Helper functions for dealing with files.

Hierarchy

  • class \Drupal\feeds\Utility\File

Expanded class hierarchy of File

2 files declare their use of File
DirectoryFetcher.php in src/Feeds/Fetcher/DirectoryFetcher.php
DirectoryFetcherFeedForm.php in src/Feeds/Fetcher/Form/DirectoryFetcherFeedForm.php
1 string reference to 'File'
UploadFetcherFeedForm::buildConfigurationForm in src/Feeds/Fetcher/Form/UploadFetcherFeedForm.php
Form constructor.

File

src/Utility/File.php, line 8

Namespace

Drupal\feeds\Utility
View source
class File {

  /**
   * Checks that the filename ends with an allowed extension.
   *
   * @param string $filename
   *   A file path.
   * @param string $extensions
   *   A string with a space separated list of allowed extensions.
   *
   * @return bool
   *   Returns true if the file is valid, false if not.
   */
  public static function validateExtension($filename, $extensions) {
    $regex = '/\\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
    return (bool) preg_match($regex, $filename);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
File::validateExtension public static function Checks that the filename ends with an allowed extension.