You are here

function _patterns_parser_analyze_pattern_name in Patterns 7

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

Analyzes a pattern name and return an array of errors messages.

@TODO Doc.

Parameters

mixed $name:

3 calls to _patterns_parser_analyze_pattern_name()
patterns_parser_validate_pattern_name in includes/parser/parser.inc
Validates a pattern name.
_patterns_import_check_name in includes/forms/import.inc
Helper function to be called in one of the import validation handlers.
_patterns_io_import_check_name in includes/io/import.inc
Helper function to be called in one of the import validation handlers.

File

includes/parser/parser.inc, line 466

Code

function _patterns_parser_analyze_pattern_name($name = NULL) {
  $msgs = array();
  if (empty($name)) {
    $msgs[] = t('No pattern name provided.');
    return $msgs;
  }
  if (preg_match('/[^a-zA-Z0-9_]/', $name)) {
    $msgs[] = t('You can only include letters, numbers, and underscores in the pattern identifier.');
  }
  if (preg_match('/^_/', $name)) {
    $msgs[] = t('You cannot start the pattern identifier with an underscore.');
  }
  return $msgs;
}