function _patterns_io_file_has_valid_extension in Patterns 7.2
Same name and namespace in other branches
- 7 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 - Lower level primitive for patterns_io_save_pattern. Includes an optional argument to force the UUUID
File
- includes/
io/ io.inc, line 569 - 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;
}