You are here

function patterns_validate_pattern in Patterns 7

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_validate_pattern()
  2. 6 patterns.module \patterns_validate_pattern()
  3. 7.2 includes/parser/parser.inc \patterns_validate_pattern()

Check if pattern array or content from a file is valid.

Parameters

mixed $pattern Pattern array or content of a pattern file.:

mixed $format The format of the file to validate against.:

integer $level Optional. The level of validation required.:

Return value

bool TRUE if valid, FALSE otherwise.

3 calls to patterns_validate_pattern()
patterns_db_save_pattern in includes/db.inc
Writes the pattern metadata (and the actual pattern) to the database.
patterns_io_save_pattern in includes/io/io.inc
Saves a pattern string or array into the database AND in the file system.
patterns_io_scan_directories in includes/io/io.inc
Scan directories looking for patterns files.

File

includes/parser/parser.inc, line 273

Code

function patterns_validate_pattern($pattern, $format = PATTERNS_FORMAT_UNKNOWN, $level = PATTERNS_VALIDATE_ALL) {
  if ($level == PATTERNS_VALIDATE_SKIP) {
    return TRUE;
  }
  $pattern = patterns_parser_parse($pattern, $format);
  if (!$pattern) {
    return FALSE;
  }
  if ($level == PATTERNS_VALIDATE_FORMAT) {
    return TRUE;
  }
  $scan = patterns_scan_pattern($pattern, FALSE, $level);
  return _patterns_scan_validate_patternscan($scan, FALSE, $level);
}