You are here

function patterns_io_load_pattern_from_file in Patterns 7

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

Creates a pattern object from a file

The returned object is as if the pattern would be loaded from the database with patterns_get_pattern()

Parameters

string $file: The path to the file containing the pattern

string $format Optional.: A valid pattern format

Return value

stdClass $pattern The pattern object.

1 call to patterns_io_load_pattern_from_file()
patterns_load_file_and_start_engine in ./patterns.drush.inc

File

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

Code

function patterns_io_load_pattern_from_file($file, $format = PATTERNS_FORMAT_UNKNOWN) {
  $pattern = array();
  $content = patterns_parser_load($file, $format);
  if (!$content) {
    return FALSE;
  }
  $pattern['pattern'] = $content;
  $pattern = patterns_get_pattern_obj($pattern);
  return $pattern;
}