You are here

function patterns_execute_config in Patterns 6

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_execute_config()
  2. 7.2 includes/unused.inc \patterns_execute_config()
  3. 7 includes/unused.inc \patterns_execute_config()

Execute default configuration for module during the module installation

This function should be called by other modules from within their hook_enable() implementation. Module should also provide modulename.config file containing PHP array with the actions that need to be executed.

Parameters

$module: name of the module calling the function

File

./patterns.module, line 1344
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_execute_config($module) {

  // since this function is called from hook_enable(), we need to ensure that
  // it's executed only at module installation (first time module is enabled)
  if (drupal_get_installed_schema_version($module) == SCHEMA_INSTALLED) {
    return;
  }
  $path = drupal_get_path('module', $module) . '/' . $module . '.config';
  if (file_exists($path)) {
    include_once $path;
    if (empty($actions)) {
      return;
    }
    $pattern = new stdClass();
    $pattern->title = t('Default configuration for @module module', array(
      '@module' => $module,
    ));
    $pattern->status = false;
    $pattern->pattern['actions'] = $actions;
    patterns_execute_pattern($pattern);
  }
}