You are here

function drush_patterns_import_file in Patterns 7.2

Same name and namespace in other branches
  1. 7 patterns.drush.inc \drush_patterns_import_file()

Imports the specified patterns file

Parameters

string path to the patterns file:

string optional machine readable name for the pattern you are importing:

string optional validation level to validate the pattern:

Return value

mixed bool|string FALSE upon failure; the name of the imported pattern upon success

1 string reference to 'drush_patterns_import_file'
patterns_drush_command in ./patterns.drush.inc
Implements hook_drush_command().

File

./patterns.drush.inc, line 496
Drush Patterns module commands

Code

function drush_patterns_import_file($file, $format = PATTERNS_FORMAT_UNKNOWN, $validate_level = PATTERNS_VALIDATE_ALL) {
  switch (strtoupper($validate_level)) {
    case 'ALL':
      $validate_level = PATTERNS_VALIDATE_ALL;
      break;
    case 'SEMANTIC':
      $validate_level = PATTERNS_VALIDATE_SEMANTIC;
      break;
    case 'TAG_SYNTAX':
      $validate_level = PATTERNS_VALIDATE_TAG_SYNTAX;
      break;
    case 'TAG_EXISTS':
      $validate_level = PATTERNS_VALIDATE_TAG_EXISTS;
      break;
    case 'INCLUDE':
      $validate_level = PATTERNS_VALIDATE_INCLUDE;
      break;
    case 'SYNTAX':
      $validate_level = PATTERNS_VALIDATE_SYNTAX;
      break;
    case 'FORMAT':
      $validate_level = PATTERNS_VALIDATE_FORMAT;
      break;
    case 'SKIP':
      $validate_level = PATTERNS_VALIDATE_SKIP;
      break;
    default:
      $validate_level = PATTERNS_VALIDATE_ALL;
      break;
  }
  drush_print(dt("Importing local pattern file: " . $file));
  return patterns_io_import_file($file, $format, null, $validate_level);
}