You are here

public function WsConfigUIController::hook_menu in Web Service Data 7

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

modules/wsconfig/wsconfig.entity.inc, line 312
Entity classes

Class

WsConfigUIController
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;

  // Change the overview menu type for the list of web service configurations.
  $items[$this->path]['type'] = MENU_NORMAL_ITEM;

  // Change the add page menu to multiple types of entities
  $items[$this->path . '/add'] = array(
    'title' => t('Add a wsconfig'),
    'description' => t('Add a new Web Service Configuration'),
    'page callback' => 'wsconfig_add_page',
    'access callback' => 'wsconfig_access',
    'access arguments' => array(
      'edit',
    ),
    'type' => MENU_LOCAL_ACTION,
    'weight' => -20,
    'file' => 'wsconfig.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );

  // Add menu items to add each different type of entity.
  foreach (wsconfig_get_types() as $type) {
    $items[$this->path . '/add/' . $type->type] = array(
      'title' => 'Add ' . $type->label,
      'page callback' => 'wsconfig_form_wrapper',
      'page arguments' => array(
        wsconfig_create(array(
          'type' => $type->type,
        )),
      ),
      'access callback' => 'wsconfig_access',
      'access arguments' => array(
        'edit',
        'edit ' . $type->type,
      ),
      'file' => 'wsconfig.admin.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
    );
  }

  // Loading and editing wsconfig entities
  // Menu item for viewing web service configurations
  $items[$this->path . '/' . $wildcard] = array(
    'title callback' => 'wsconfig_page_title',
    'title arguments' => array(
      $id_count,
    ),
    'page callback' => 'wsconfig_view_form_wrapper',
    'page arguments' => array(
      $id_count,
    ),
    'access callback' => 'wsconfig_access',
    'access arguments' => array(
      'view',
      $id_count,
    ),
    'type' => MENU_CALLBACK,
    'file' => 'wsconfig.admin.inc',
    'file path' => drupal_get_path('module', $this->entityInfo['module']),
  );
  return $items;
}