You are here

public function BatEventUIController::hook_menu in Booking and Availability Management Tools for Drupal 7

Overrides hook_menu() defaults.

The main reason for doing this is that the parent class hook_menu() is optimized for entity type administration.

Overrides EntityDefaultUIController::hook_menu

File

modules/bat_event/bat_event.admin.inc, line 28
Unit event editing UI.

Class

BatEventUIController
UI controller.

Code

public function hook_menu() {
  $items = array();
  $id_count = count(explode('/', $this->path));
  $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%' . $this->entityType;
  $items[$this->path] = array(
    'title' => 'Events',
    'description' => 'Add edit and update events.',
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array(
      'access administration pages',
    ),
    'file path' => drupal_get_path('module', 'system'),
    'file' => 'system.admin.inc',
    'weight' => 10,
  );

  // Change the add page menu to multiple types of entities.
  $items[$this->path . '/add'] = array(
    'title' => 'Add an Event',
    'description' => 'Add a new Event',
    'page callback' => 'bat_event_add_page',
    'access callback' => 'bat_event_add_access',
    'type' => MENU_NORMAL_ITEM,
    'weight' => 20,
    'file' => 'bat_event.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Add menu items to add each different type of unit.
  foreach (bat_event_get_types() as $type) {
    $items[$this->path . '/add/' . $type->type] = array(
      'title' => 'Add @event_type',
      'title arguments' => array(
        '@event_type' => $type->label,
      ),
      'page callback' => 'bat_event_create_form_wrapper',
      'page arguments' => array(
        $type->type,
      ),
      'access callback' => 'bat_event_access',
      'access arguments' => array(
        'create',
        bat_event_create(array(
          'type' => $type->type,
          'uid' => 0,
        )),
      ),
      'file' => 'bat_event.admin.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );
  }

  // Menu items for loading and editing Unit entities.
  $items[$this->path . '/event/' . $wildcard] = array(
    'page callback' => 'bat_event_form_wrapper',
    'page arguments' => array(
      $id_count + 1,
    ),
    'access callback' => 'bat_event_access',
    'access arguments' => array(
      'update',
      $id_count + 1,
    ),
    'weight' => 0,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'file' => 'bat_event.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );
  $items[$this->path . '/event/' . $wildcard . '/edit'] = array(
    'title' => 'Edit',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items[$this->path . '/event/' . $wildcard . '/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'bat_event_delete_form_wrapper',
    'page arguments' => array(
      $id_count + 1,
    ),
    'access callback' => 'bat_event_access',
    'access arguments' => array(
      'delete',
      $id_count + 1,
    ),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
    'weight' => 10,
    'file' => 'bat_event.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Menu item for viewing units.
  $items['event/' . $wildcard] = array(
    'title callback' => 'bat_event_page_title',
    'title arguments' => array(
      1,
    ),
    'page callback' => 'bat_event_page_view',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'bat_event_access',
    'access arguments' => array(
      'view',
      1,
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}