You are here

function patterns_export_core_php in Patterns 7.2

Same name and namespace in other branches
  1. 7 patterns_export/core.inc \patterns_export_core_php()

Constructs the abstract representation of the exported pattern

Returns the array of needed modules, and the actions of the pattern.

Parameters

array $tagmodules An index of modules and tag to export:

array $args Set of arguments passed to the export functions:

Return value

array $result An array containing modules and actions

1 call to patterns_export_core_php()
patterns_export_php in patterns_export/core.inc
Starts the exporting process in php execution mode

File

patterns_export/core.inc, line 38

Code

function patterns_export_core_php($tagmodules, $args) {
  $result = array();
  $modules = array();
  foreach ($tagmodules as $module_name => $module) {
    foreach ($module as $tag => $values) {
      if (!isset($values[PATTERNS_EXPORT]) || empty($values[PATTERNS_EXPORT])) {
        continue;
      }
      if (isset($values[PATTERNS_FILES])) {
        $files = !is_array($values[PATTERNS_FILES]) ? array(
          $values[PATTERNS_FILES],
        ) : $values[PATTERNS_FILES];
        foreach ($files as $file) {
          require_once $file;
        }
      }

      // TODO: the name of the component may be different from the
      // the name of the module to enable. Cover this case
      array_push($modules, $module_name);
      if (!is_array($values[PATTERNS_EXPORT])) {
        $sections[$tag] = call_user_func($values[PATTERNS_EXPORT], $args);
      }
      else {
        foreach ($values[PATTERNS_EXPORT] as $f) {
          $result[$tag] = isset($result[$tag]) ? $result[$tag] : array();
          $sections[$tag] = array_merge($result[$tag], call_user_func($f, $args));
        }
      }
    }
  }
  $result[] = $sections;
  $result[] = $modules;
  return $result;
}