You are here

function uuid_menu in Universally Unique IDentifier 7

Same name and namespace in other branches
  1. 6 uuid.module \uuid_menu()

Implements hook_menu().

File

./uuid.module, line 30
Main module functions for the uuid module.

Code

function uuid_menu() {
  $items = array();
  $items['uuid'] = array(
    'title' => 'UUID redirector',
    'description' => 'Redirects requests for UUID URIs to the referenced entity.',
    'page callback' => 'uuid_redirector',
    // The access check is handled in the page callback.
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['admin/config/system/uuid'] = array(
    'title' => 'Universally unique identifiers',
    'description' => 'Configure universally unique identifiers.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'uuid_admin_form',
    ),
    'access arguments' => array(
      'administer uuid',
    ),
    'file' => 'uuid.admin.inc',
  );

  // Conditional support for Devel. A good thing for developers.
  if (module_exists('devel')) {
    $entity_types = array(
      'user' => array(
        'path' => 'user/%user/devel/load-by-uuid',
        'arg' => 1,
      ),
      'node' => array(
        'path' => 'node/%node/devel/load-by-uuid',
        'arg' => 1,
      ),
      'comment' => array(
        'path' => 'comment/%comment/devel/load-by-uuid',
        'arg' => 1,
      ),
      'taxonomy_term' => array(
        'path' => 'taxonomy/term/%taxonomy_term/devel/load-by-uuid',
        'arg' => 2,
      ),
    );
    foreach ($entity_types as $entity_type => $info) {
      $items[$info['path']] = array(
        'title' => 'Load by UUID',
        'page callback' => 'uuid_devel_load_by_uuid',
        'page arguments' => array(
          $entity_type,
          $info['arg'],
        ),
        'access arguments' => array(
          'access devel information',
        ),
        'type' => MENU_LOCAL_TASK,
        'file' => 'uuid.admin.inc',
        'weight' => 100,
      );
    }
  }
  return $items;
}