You are here

domain_test.module in Domain Access 7.3

Test module for Domain Access.

File

tests/domain_test.module
View source
<?php

/**
 * @file
 * Test module for Domain Access.
 */

/**
 * Store static variables to indicate that hooks fired.
 */
function domain_test_set($value = NULL) {
  static $storage;
  if (is_null($value) && isset($storage)) {
    return $storage;
  }
  $storage = $value;
}

/**
 * Get the static value.
 */
function domain_test_get() {
  return domain_test_set();
}

/**
 * Implements hook_domain_bootstrap_lookup().
 *
 * Match 'local.test' to 'newtest.example.com'.
 */
function domain_test_domain_bootstrap_lookup($domain) {
  $subdomain = $domain['subdomain'];
  if ($subdomain != 'local.test') {
    return;
  }
  $default = domain_default();
  $domain = domain_lookup(NULL, 'newtest.' . $default['subdomain'], TRUE);
  return $domain;
}

/**
 * Implements hook_domain_bootstrap_full().
 *
 * Add a $domain['test_full'] element to the array.
 */
function domain_test_domain_bootstrap_full($domain) {
  $GLOBALS['_domain']['test_full'] = TRUE;
}

/**
 * Implements hook_node_insert().
 */
function domain_test_node_insert($node) {
  drupal_set_message(token_replace('Inserted node [node:title] assigned to domain [node:domain:id] ([node:domain]).', array(
    'node' => $node,
  )));
}

/**
 * Implements hook_node_update().
 */
function domain_test_node_update($node) {
  drupal_set_message(token_replace('Updated node [node:title] assigned to domain [node:domain:id] ([node:domain]).', array(
    'node' => $node,
  )));
}

Functions