You are here

function _patterns_io_file_has_valid_extension in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/io/io.inc \_patterns_io_file_has_valid_extension()

Checks whether the extension of the specified file name matches one of the currently available parser formats.

Parameters

mixed $file String representing a file name.:

array $formats (optional) The array of valid formats,: against which checking the file extension. If NULL, rebuilds the index of currently available formats.

Return value

bool Boolean. TRUE, if the extension matches an available parser.

2 calls to _patterns_io_file_has_valid_extension()
drush_patterns_run in ./patterns.drush.inc
Imports, enables, and runs the specified pattern file
patterns_io_save_pattern in includes/io/io.inc
Saves a pattern string or array into the database AND in the file system.

File

includes/io/io.inc, line 534
Functions related to input/output operations.

Code

function _patterns_io_file_has_valid_extension($file = NULL, $formats = NULL) {
  if (is_null($file)) {
    return FALSE;
  }
  if (is_null($formats)) {
    $formats = patterns_parser_get_formats();
  }
  $ext = pathinfo($file, PATHINFO_EXTENSION);
  return in_array($ext, $formats) ? TRUE : FALSE;
}