You are here

function spaces_router in Spaces 7.3

Same name and namespace in other branches
  1. 5.2 spaces.module \spaces_router()
  2. 5 spaces.module \spaces_router()
  3. 6.3 spaces.module \spaces_router()
  4. 6 spaces.module \spaces_router()
  5. 6.2 spaces.module \spaces_router()
  6. 7 spaces.module \spaces_router()

Calls the router method on all space types, giving them a chance to route requests accordingly.

Parameters

$op: The current "hook" or "hook op" identifier for the $space->router to act on.

$object: Optional object to pass to the $space->router.

1 call to spaces_router()
spaces_init in ./spaces.module
Implements hook_init().

File

./spaces.module, line 373

Code

function spaces_router($op, $object = NULL) {
  static $router;
  if (!isset($router)) {
    $router = array();

    // Add the active space.
    if ($space = spaces_get_space()) {
      $router[$space->type] = $space;
    }

    // Iterate over space types and create instances of each.
    ctools_include('plugins');
    $plugins = ctools_get_plugins('spaces', 'plugins');
    foreach (spaces_types() as $type => $info) {
      if (!isset($router[$type]) && isset($plugins[$info['plugin']]) && ($class = ctools_plugin_get_class($plugins[$info['plugin']], 'handler'))) {
        $router[$type] = new $class($type);
      }
    }
  }
  foreach ($router as $space) {
    $space
      ->router($op, $object);
  }
}