You are here

function patterns_api_add_modules_section in Patterns 7.2

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

Adds / Replaces the 'modules' section in a pattern.

Removes duplicates from the list of modules.

Parameters

array $modules: Array containing the name of the modules

array $pattern (optional): The associative array representing a pattern

Bool $ow (optional): If TRUE, a pre-existing modules section will be overwritten. Defaults FALSE.

Return value

Bool|Array Return the array containing the the modules section, or FALSE if an error occurred

1 call to patterns_api_add_modules_section()
_patterns_export_merge_exported_patterns in patterns_export/finalize.inc
Merges modules info and sections in one pattern

File

includes/api/api.inc, line 77
API for writing pattern files.

Code

function patterns_api_add_modules_section($modules = NULL, &$pattern = array(), $ow = FALSE) {
  if (empty($modules)) {
    return FALSE;
  }
  if (isset($pattern['modules']) && !$ow) {
    return FALSE;
  }
  $modules = is_array($modules) ? $modules : array(
    $modules,
  );
  $pattern['modules'] = array_unique($modules);
  return $pattern;
}