class BatUnitUIController in Booking and Availability Management Tools for Drupal 7
UI controller.
Hierarchy
- class \EntityDefaultUIController
- class \BatUnitUIController
Expanded class hierarchy of BatUnitUIController
1 string reference to 'BatUnitUIController'
- bat_unit_entity_info in modules/
bat_unit/ bat_unit.module - Implements hook_entity_info().
File
- modules/
bat_unit/ bat_unit.admin.inc, line 15 - BatUnit editing UI.
View source
class BatUnitUIController extends EntityDefaultUIController {
/**
* Overrides hook_menu() defaults.
*/
public function hook_menu() {
$items = parent::hook_menu();
$items['admin/bat/config/units']['access callback'] = FALSE;
$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 units.';
$items[$this->path]['weight'] = 10;
// Change the add page menu to multiple types of entities.
$items[$this->path . '/add']['title'] = 'Add a Unit';
$items[$this->path . '/add']['description'] = 'Create a new unit.';
$items[$this->path . '/add']['page callback'] = 'bat_unit_add_page';
$items[$this->path . '/add']['access callback'] = 'bat_unit_add_access';
unset($items[$this->path . '/add']['title callback']);
// Add menu items to add each different type of units.
foreach (bat_unit_get_bundles() as $bundle) {
$items[$this->path . '/add/' . $bundle->type] = array(
'title' => 'Add @unit_bundle_label unit',
'title arguments' => array(
'@unit_bundle_label' => $bundle->label,
),
'page callback' => 'bat_unit_create_form_wrapper',
'page arguments' => array(
$bundle->type,
),
'access callback' => 'bat_unit_access',
'access arguments' => array(
'create',
bat_unit_create(array(
'type' => $bundle->type,
'uid' => 0,
)),
),
'file' => 'bat_unit.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
}
// Loading and editing Unit entities.
$items[$this->path . '/unit/' . $wildcard] = array(
'title callback' => 'bat_unit_page_title',
'title arguments' => array(
$id_count + 1,
),
'page callback' => 'bat_unit_page_view',
'page arguments' => array(
$id_count + 1,
),
'access callback' => 'bat_unit_access',
'access arguments' => array(
'view',
$id_count + 1,
),
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
);
$items[$this->path . '/unit/' . $wildcard . '/edit'] = array(
'title' => 'Edit',
'page callback' => 'bat_unit_form_wrapper',
'page arguments' => array(
$id_count + 1,
),
'access callback' => 'bat_unit_access',
'access arguments' => array(
'update',
$id_count + 1,
),
'weight' => 0,
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'file' => 'bat_unit.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
$items[$this->path . '/unit/' . $wildcard . '/delete'] = array(
'title' => 'Delete',
'page callback' => 'bat_unit_delete_form_wrapper',
'page arguments' => array(
$id_count + 1,
),
'access callback' => 'bat_unit_access',
'access arguments' => array(
'delete',
$id_count + 1,
),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
'weight' => 10,
'file' => 'bat_unit.admin.inc',
'file path' => drupal_get_path('module', $this->entityInfo['module']),
);
// Menu item for viewing unit.
$items['unit/' . $wildcard] = array(
'title callback' => 'bat_unit_page_title',
'title arguments' => array(
1,
),
'page callback' => 'bat_unit_page_view',
'page arguments' => array(
1,
),
'access callback' => 'bat_unit_access',
'access arguments' => array(
'view',
1,
),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Creates the markup for the add Unit Entities page within the class
* so it can easily be extended/overridden.
*/
public function addPage() {
$item = menu_get_item();
$bundles = bat_unit_get_bundles();
// If there is only one unit bundle go straight to that page.
if (count($bundles) == 1) {
$bundle = reset($bundles);
drupal_goto($this->path . '/add/' . $bundle->type);
}
$items = array();
foreach ($bundles as $bundle) {
$items[] = array(
'title' => t('Add @unit_bundle_label unit', array(
'@unit_bundle_label' => $bundle->label,
)),
'href' => $this->path . '/add/' . $bundle->type,
'description' => '',
);
}
return array(
'#theme' => 'bat_unit_add_list',
'#content' => $items,
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BatUnitUIController:: |
public | function | Creates the markup for the add Unit Entities page within the class so it can easily be extended/overridden. | |
BatUnitUIController:: |
public | function |
Overrides hook_menu() defaults. Overrides EntityDefaultUIController:: |
|
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
protected | property | ||
EntityDefaultUIController:: |
public | property | Defines the number of entries to show per page in overview table. | |
EntityDefaultUIController:: |
public | function | Applies an operation to the given entity. | |
EntityDefaultUIController:: |
public | function | Entity submit builder invoked via entity_ui_form_submit_build_entity(). | |
EntityDefaultUIController:: |
public | function | Provides definitions for implementing hook_forms(). | |
EntityDefaultUIController:: |
protected | function | Returns the operation count for calculating colspans. | |
EntityDefaultUIController:: |
public | function | Builds the operation form. | |
EntityDefaultUIController:: |
public | function | Operation form submit callback. | 1 |
EntityDefaultUIController:: |
public | function | Operation form validation callback. | |
EntityDefaultUIController:: |
public | function | Builds the entity overview form. | |
EntityDefaultUIController:: |
public | function | Overview form submit callback. | |
EntityDefaultUIController:: |
public | function | Overview form validation callback. | |
EntityDefaultUIController:: |
public | function | Generates the render array for a overview table for arbitrary entities matching the given conditions. | |
EntityDefaultUIController:: |
protected | function | Generates the table headers for the overview table. | |
EntityDefaultUIController:: |
protected | function | Generates the row for the passed entity and may be overridden in order to customize the rows. | |
EntityDefaultUIController:: |
public | function |