You are here

xautoload.install in X Autoload 7.3

Same filename and directory in other branches
  1. 7.5 xautoload.install
  2. 7.4 xautoload.install

File

xautoload.install
View source
<?php

/**
 * Implements hook_install()
 */
function xautoload_install() {

  // Set module weight for xautoload to run before other modules.
  db_query("UPDATE {system} SET weight = -90 WHERE name = 'xautoload' AND type = 'module'");
}

/**
 * Implements hook_uninstall()
 */
function xautoload_uninstall() {
  variable_del('xautoload_cache_mode');
}

/**
 * Implements hook_enable()
 */
function xautoload_enable() {

  // This could be a process of enabling multiple modules.
  // The database does not have these other modules as enabled yet.
  // So we get them from the stack trace.
  $trace = debug_backtrace(0);
  if (1 && isset($trace[3]['function']) && 'module_enable' === $trace[3]['function'] && is_array($trace[3]['args'][0])) {
    foreach (array_unique($trace[3]['args'][0]) as $module) {
      $modules = array();
      if (!empty($module)) {
        $modules[] = $module;
      }

      // Register modules in autoloader.
      $q = db_select('system', 's');
      $q
        ->fields('s', array(
        'name',
        'filename',
        'type',
      ));
      $q
        ->condition('s.name', $modules);
      $extensions = $q
        ->execute()
        ->fetchAll();
      xautoload('registrationHelper')
        ->registerExtensions($extensions);
    }
  }
}

/**
 * Implements hook_update_N()
 */
function xautoload_update_7000() {

  // Set module weight for xautoload to run before other modules.
  db_query("UPDATE {system} SET weight = -90 WHERE name = 'xautoload' AND type = 'module'");
}