You are here

public function CivicrmEntityUIController::hook_menu in CiviCRM Entity 7.2

Provides definitions for implementing hook_menu().

Overrides EntityContentUIController::hook_menu

File

./civicrm_entity_ui_controller.inc, line 59

Class

CivicrmEntityUIController

Code

public function hook_menu() {

  /* add menu items for all entities, will display with id as argument to url
   * for example goto <drupal_root>/civicrm_contact/1, in the example id =1
   */
  $civicrm_entities = _civicrm_entity_enabled_entities();
  foreach ($civicrm_entities as $key => $value) {
    $dashkey = str_replace('_', '-', $key);
    $titlename = ucwords(str_replace('_', ' ', $key));
    $items[$dashkey . '/add'] = array(
      'title' => 'Create ' . $key,
      'page callback' => 'entity_ui_get_form',
      'page arguments' => array(
        $key,
        array(),
        'create',
      ),
      'access callback' => 'civicrm_entity_op_access',
      'access arguments' => array(
        'create',
        $key,
      ),
      'type' => MENU_CALLBACK,
    );
    $items[$dashkey . '/' . '%civicrm_entity_loader'] = array(
      //'title' => 'Title',
      'title callback' => $key . '_page_title',
      'title arguments' => array(
        1,
      ),
      'page callback' => 'civicrm_entity_page_view',
      'page arguments' => array(
        1,
        $key,
      ),
      'access callback' => 'civicrm_entity_op_access',
      'access arguments' => array(
        'view',
        $key,
        1,
      ),
      'load arguments' => array(
        $key,
      ),
    );
    $items[$dashkey . '/%civicrm_entity_loader/view'] = array(
      'title' => 'View',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -10,
      'load arguments' => array(
        $key,
      ),
    );
    $items[$dashkey . '/' . '%civicrm_entity_loader/edit'] = array(
      'title' => 'Edit',
      'page callback' => 'entity_ui_get_form',
      'page arguments' => array(
        $key,
        1,
        'edit',
      ),
      'access callback' => 'civicrm_entity_op_access',
      'access arguments' => array(
        'edit',
        $key,
        1,
      ),
      'type' => MENU_LOCAL_TASK,
      'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      'load arguments' => array(
        $key,
      ),
    );
    $items[$dashkey . '/' . '%civicrm_entity_loader/delete'] = array(
      'title' => 'Delete',
      'page callback' => 'entity_ui_get_form',
      'page arguments' => array(
        $key,
        1,
        'delete',
      ),
      'access callback' => 'civicrm_entity_op_access',
      'access arguments' => array(
        'delete',
        $key,
        1,
      ),
      'type' => MENU_LOCAL_TASK,
      'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
      'weight' => 10,
      'load arguments' => array(
        $key,
      ),
    );
  }
  return $items;
}