You are here

public function CaseTrackerProjectUIController::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/CaseTrackerProjectUIController.inc, line 12

Class

CaseTrackerProjectUIController
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;
  $operations_path = 'projects';

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

  // Add menu items to add each different type of entity.
  foreach (casetracker_project_get_types() as $type) {
    $items[$operations_path . '/add/' . $type->type] = array(
      'title' => t('Add @bundle', array(
        '@bundle' => $type->label,
      )),
      'page callback' => 'casetracker_project_form_wrapper',
      'page arguments' => array(
        casetracker_project_create(array(
          'type' => $type->type,
        )),
      ),
      'access callback' => 'casetracker_project_access',
      'access arguments' => array(
        'edit',
        'edit ' . $type->type,
      ),
      'file' => 'casetracker_project.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );
  }
  $project_path = 'project';
  $items[$project_path . '/' . $wildcard . '/edit'] = array(
    'title' => t('Edit'),
    'page callback' => 'casetracker_project_form_wrapper',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'casetracker_project_access',
    'access arguments' => array(
      'edit',
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 0,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  );
  $items[$project_path . '/' . $wildcard . '/delete'] = array(
    'title' => t('Delete'),
    'page callback' => 'casetracker_project_delete_form_wrapper',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'casetracker_project_access',
    'access arguments' => array(
      'edit',
      1,
    ),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,
    'weight' => 10,
    'file' => 'casetracker_project.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Menu item for viewing casetracker_projects
  $items[$project_path . '/' . $wildcard] = array(
    'page callback' => 'casetracker_project_page_view',
    'page arguments' => array(
      1,
    ),
    'access callback' => 'casetracker_project_access',
    'access arguments' => array(
      'view',
      1,
    ),
  );
  $items[$project_path . '/' . $wildcard . '/view'] = array(
    'title' => t('View'),
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  return $items;
}