You are here

xautoload_test_1.module in X Autoload 7.3

File

tests/test_1/xautoload_test_1.module
View source
<?php

/**
 * Implements hook_boot()
 *
 * This turns xautoload_test_1 into a boot module.
 */
function xautoload_test_1_boot() {
  _xautoload_test_1_early_boot_observations('boot');
}
_xautoload_test_1_early_boot_observations('early');

/**
 * Test the current state, and remember it.
 */
function _xautoload_test_1_early_boot_observations($phase = NULL) {
  static $all = array();
  if (!isset($phase)) {
    $return = $all;
    foreach ($return as $phase => &$observations) {

      // Turn callbacks into strings, so they survive json_decode().
      foreach ($observations['spl_autoload_functions'] as &$callback) {

        // At this point in time we can be fairly sure
        // that xautoload_Util is available.
        $callback = xautoload_Util::callbackToString($callback);
      }
    }
    return $return;
  }

  // Test that all classes are available immediately at boot time.
  foreach (array(
    'Drupal\\xautoload_test_1\\ExampleClass',
    'xautoload_test_1_ExampleClass',
  ) as $class) {
    $observations[$class] = class_exists($class);
  }

  // Check variable_get().
  $observations['xautoload_cache_mode'] = variable_get('xautoload_cache_mode');
  $observations['db_connection_info'] = Database::getConnectionInfo();
  $observations['spl_autoload_functions'] = spl_autoload_functions();
  $all[$phase] = $observations;
}

/**
 * Implements hook_menu()
 */
function xautoload_test_1_menu() {
  return array(
    'xautoload_test_1.json' => array(
      'page callback' => '_xautoload_test_1_json',
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
    ),
  );
}

/**
 * Page callback for "xautoload-example/json"
 */
function _xautoload_test_1_json() {
  $all = _xautoload_test_1_early_boot_observations();
  drupal_json_output($all);
  exit;
}

Functions

Namesort descending Description
xautoload_test_1_boot Implements hook_boot()
xautoload_test_1_menu Implements hook_menu()
_xautoload_test_1_early_boot_observations Test the current state, and remember it.
_xautoload_test_1_json Page callback for "xautoload-example/json"