public function BatTypeUIController::hook_menu in Booking and Availability Management Tools for Drupal 7
Overrides hook_menu() defaults.
Overrides EntityDefaultUIController::hook_menu
File
- modules/
bat_unit/ bat_type.admin.inc, line 20 - BatType editing UI.
Class
- BatTypeUIController
- UI controller.
Code
public function hook_menu() {
$items = parent::hook_menu();
$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]['description'] = 'Add, edit, and update Types.';
$items[$this->path]['weight'] = 10;
// Change the add page menu to multiple types of entities.
$items[$this->path . '/add']['title'] = 'Add a Type';
$items[$this->path . '/add']['description'] = 'Create a new Type.';
$items[$this->path . '/add']['page callback'] = 'bat_type_add_page';
$items[$this->path . '/add']['access callback'] = 'bat_type_add_access';
unset($items[$this->path . '/add']['title callback']);
// Add menu items to add each different bundle of Bat Types.
foreach (bat_unit_get_type_bundles() as $bundle) {
$items[$this->path . '/add/' . $bundle->type] = array(
'title' => 'Add @type_bundle_label type',
'title arguments' => array(
'@type_bundle_label' => $bundle->label,
),
'page callback' => 'bat_type_create_form_wrapper',
'page arguments' => array(
$bundle->type,
),
'access callback' => 'bat_type_access',
'access arguments' => array(
'create',
bat_type_create(array(
'type' => $bundle->type,
'uid' => 0,
)),
),
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
}
// Loading and editing type entities.
$items[$this->path . '/manage/' . $wildcard] = array(
'title callback' => 'bat_type_page_title',
'title arguments' => array(
$id_count + 1,
),
'page callback' => 'bat_type_page_view',
'page arguments' => array(
$id_count + 1,
),
'access callback' => 'bat_type_access',
'access arguments' => array(
'view',
$id_count + 1,
),
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
);
$items[$this->path . '/manage/' . $wildcard . '/view'] = array(
'title callback' => 'bat_type_title_callback',
'title arguments' => array(
$id_count + 1,
'view',
),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
);
if (module_exists('diff')) {
$items[$this->path . '/manage/' . $wildcard . '/revisions/view'] = array(
'title' => '',
'page callback' => 'bat_type_compare_revisions',
'page arguments' => array(
$id_count + 1,
$id_count + 4,
$id_count + 5,
),
'access callback' => TRUE,
'type' => MENU_LOCAL_TASK,
'file' => 'bat_type.diff.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
}
$items[$this->path . '/manage/' . $wildcard . '/revision/%/view'] = array(
'title' => 'View Revision',
'page callback' => 'bat_type_revision_view',
'page arguments' => array(
$id_count + 1,
$id_count + 3,
),
'access callback' => 'bat_type_access_revision',
'access arguments' => array(
'view',
$id_count + 1,
$id_count + 3,
),
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
$items[$this->path . '/manage/' . $wildcard . '/revision/%/revert'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array(
'bat_type_revision_revert_confirm',
$id_count + 1,
$id_count + 3,
),
'access callback' => 'bat_type_access_revision',
'access arguments' => array(
'revert',
$id_count + 1,
$id_count + 3,
),
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
$items[$this->path . '/manage/' . $wildcard . '/revision/%/delete'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array(
'bat_type_revision_delete_confirm',
$id_count + 1,
$id_count + 3,
),
'access callback' => 'bat_type_access_revision',
'access arguments' => array(
'delete',
$id_count + 1,
$id_count + 3,
),
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
$items[$this->path . '/manage/' . $wildcard . '/edit'] = array(
'title callback' => 'bat_type_title_callback',
'title arguments' => array(
$id_count + 1,
'edit',
),
'page callback' => 'bat_type_form_wrapper',
'page arguments' => array(
$id_count + 1,
),
'access callback' => 'bat_type_access',
'access arguments' => array(
'update',
$id_count + 1,
),
'weight' => 0,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
$items[$this->path . '/manage/' . $wildcard . '/delete'] = array(
'title' => 'Delete',
'page callback' => 'bat_type_delete_form_wrapper',
'page arguments' => array(
$id_count + 1,
),
'access callback' => 'bat_type_access',
'access arguments' => array(
'delete',
$id_count + 1,
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 10,
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
// Menu item for viewing types.
$items['type/' . $wildcard] = array(
'title callback' => 'bat_type_page_title',
'title arguments' => array(
1,
),
'page callback' => 'bat_type_page_view',
'page arguments' => array(
1,
),
'access callback' => 'bat_type_access',
'access arguments' => array(
'view',
1,
),
'type' => MENU_CALLBACK,
);
$items[$this->path . '/manage/' . $wildcard . '/units/add'] = array(
'title' => 'Add Units',
'page callback' => 'bat_type_add_units_page',
'page arguments' => array(
5,
),
'access arguments' => array(
'create bat_unit entities',
),
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
'type' => MENU_CALLBACK,
);
foreach (bat_unit_get_bundles() as $bundle) {
$items[$this->path . '/manage/' . $wildcard . '/units/add/' . $bundle->type] = array(
'title' => 'Add @unit_bundle_label unit',
'title arguments' => array(
'@unit_bundle_label' => $bundle->label,
),
'page callback' => 'bat_type_add_units_form_wrapper',
'page arguments' => array(
5,
8,
),
'access callback' => 'bat_unit_access',
'access arguments' => array(
'create',
bat_unit_create(array(
'type' => $bundle->type,
'uid' => 0,
)),
),
'file' => 'bat_type.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
}
return $items;
}