You are here

public static function File::validateExtension in Feeds 8.3

Checks that the filename ends with an allowed extension.

Parameters

string $filename: A file path.

string $extensions: A string with a space separated list of allowed extensions.

Return value

bool Returns true if the file is valid, false if not.

3 calls to File::validateExtension()
DirectoryFetcher::fetch in src/Feeds/Fetcher/DirectoryFetcher.php
Fetch content from a feed and return it.
DirectoryFetcher::listFiles in src/Feeds/Fetcher/DirectoryFetcher.php
Returns an array of files in a directory.
DirectoryFetcherFeedForm::validateConfigurationForm in src/Feeds/Fetcher/Form/DirectoryFetcherFeedForm.php
Form validation handler.

File

src/Utility/File.php, line 21

Class

File
Helper functions for dealing with files.

Namespace

Drupal\feeds\Utility

Code

public static function validateExtension($filename, $extensions) {
  $regex = '/\\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
  return (bool) preg_match($regex, $filename);
}