You are here

public function CaseTrackerCaseUIController::hook_menu in Case Tracker 7.2

Overrides hook_menu() defaults. Main reason for doing this is that parent class hook_menu() is optimized for entity type administration.

Overrides EntityDefaultUIController::hook_menu

File

includes/controller/ui/CaseTrackerCaseUIController.inc, line 12

Class

CaseTrackerCaseUIController
UI controller.

Code

public function hook_menu() {
  $items = array();
  $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%' . $this->entityType;
  $case_path = 'project/%/case';

  // Change the add page menu to multiple types of entities
  $items[$case_path . '/add'] = array(
    'title' => t('Add a case'),
    'description' => t('Add a new case'),
    'page callback' => 'casetracker_case_add_page',
    'access callback' => 'casetracker_case_access',
    'access arguments' => array(
      'edit',
    ),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 20,
    'file' => 'casetracker_case.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Add menu items to add each different type of entity.
  foreach (casetracker_case_get_types() as $type) {
    $items[$case_path . '/add/' . $type->type] = array(
      'title' => t('Add @bundle', array(
        '@bundle' => $type->label,
      )),
      'page callback' => 'casetracker_case_form_wrapper',
      'page arguments' => array(
        casetracker_case_create(array(
          'type' => $type->type,
        )),
      ),
      'access callback' => 'casetracker_case_access',
      'access arguments' => array(
        'edit',
        'edit ' . $type->type,
      ),
      'file' => 'casetracker_case.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );
  }
  $items[$case_path . '/' . $wildcard . '/edit'] = array(
    'title' => t('Edit'),
    'page callback' => 'casetracker_case_form_wrapper',
    'page arguments' => array(
      3,
    ),
    'access callback' => 'casetracker_case_access',
    'access arguments' => array(
      'edit',
      3,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items[$case_path . '/' . $wildcard . '/delete'] = array(
    'title' => t('Delete'),
    'page callback' => 'casetracker_case_delete_form_wrapper',
    'page arguments' => array(
      3,
    ),
    'access callback' => 'casetracker_case_access',
    'access arguments' => array(
      'edit',
      3,
    ),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
    'weight' => 10,
    'file' => 'casetracker_case.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Menu item for viewing casetracker_cases
  $items[$case_path . '/' . $wildcard] = array(
    'page callback' => 'casetracker_case_page_view',
    'page arguments' => array(
      3,
    ),
    'access callback' => 'casetracker_case_access',
    'access arguments' => array(
      'view',
      3,
    ),
  );
  $items[$case_path . '/' . $wildcard . '/view'] = array(
    'title' => t('View'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  return $items;
}