You are here

public function ConfigPagesUIController::hook_menu in Config Pages 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

./config_pages.admin.inc, line 20
ConfigPages editing UI.

Class

ConfigPagesUIController
UI controller.

Code

public function hook_menu() {
  $items = array();

  // Add menu items to each different type of entity.
  foreach (config_pages_get_types() as $type) {

    // For default local tasks we need to create a root element + local task.
    if ($type->data['menu']['type'] == MENU_DEFAULT_LOCAL_TASK) {
      $parts = explode('/', $type->data['menu']['path']);
      $items[$type->data['menu']['path'] . '/' . array_pop($parts)] = array(
        'title' => $type->label,
        'type' => $type->data['menu']['type'],
        'weight' => -10,
      );

      // This will create actual page later.
      $type->data['menu']['type'] = MENU_NORMAL_ITEM;
    }

    // Create base item.
    $items[$type->data['menu']['path']] = array(
      'title' => $type->label,
      'page callback' => 'config_pages_form_wrapper',
      'page arguments' => array(
        $type->type,
      ),
      'access callback' => 'config_pages_access',
      'access arguments' => array(
        'edit',
        'edit ' . $type->type,
      ),
      'file' => 'config_pages.admin.inc',
      'file path' => drupal_get_path('module', $this->entityInfo['module']),
      'type' => $type->data['menu']['type'],
    );
  }
  return $items;
}