You are here

function patterns_parser_dump in Patterns 7.2

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

Tries to dump an array representing a pattern to a string, according to the specified format.

If succesfull returns the array representation of the pattern, if not returns FALSE;

Parameters

mixed $pattern A string representation of the pattern, or a pattern: array. In the latter case, the array is returned as it is, and the @param $format is ignored.

mixed $format The format against which parse the pattern string.:

mixed $append (optional) A string to which the dump will be: appended. Defaults NULL

Return value

bool|mixed The string representation of the pattern or FALSE.

5 calls to patterns_parser_dump()
patterns_create_zip in includes/io/download.inc
Prepares a zip archive of patterns files and serves the file to download
patterns_export_to_file in patterns_export/finalize.inc
Exports a pattern as a donwlodable text file
patterns_lab_submit in includes/forms/lab.inc
Exports selected patterns either in a file or as a zip-archive
_patterns_editor_dump_from_db in includes/forms/editor.inc
Helper function which returns the pattern dumped from the database, or an error string.
_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/parser/parser.inc, line 180

Code

function patterns_parser_dump($pattern, $format = PATTERNS_FORMAT_UNKNOWN, $append = NULL) {
  if (empty($pattern)) {
    return FALSE;
  }
  if (is_string($pattern)) {
    return $pattern;
  }
  if (!is_array($pattern)) {
    return FALSE;
  }
  $dump_function = patterns_parser_get_parser_function($format, PATTERNS_PARSER_DUMP);
  if (!$dump_function) {
    return FALSE;
  }
  return $dump_function($pattern, $append);
}