function eck__entity__menu in Entity Construction Kit (ECK) 7
Same name and namespace in other branches
- 7.3 eck.entity.inc \eck__entity__menu()
- 7.2 eck.entity.inc \eck__entity__menu()
This function creates the menu items related to entity administration
Parameters
$entity_type: (String) the entity type
$bundle: (String) the bundle of the entity
this function is called from hook_menu()
See also
eck_menu()
1 call to eck__entity__menu()
- eck__bundle__menu in ./
eck.bundle.inc - This function creates the menu items relevant to bundle administration
File
- ./
eck.entity.inc, line 17 - All the menus, pages, and functionality related to administering entities.
Code
function eck__entity__menu($entity_type, $bundle) {
$menu = array();
// DELETE Bundle
$menu["admin/structure/eck/{$entity_type->name}/{$bundle->name}/delete"] = array(
'title' => "Delete {$entity_type->name}'s Bundle: {$bundle->name}",
'page callback' => "drupal_get_form",
//"eck__bundle__delete",
'page arguments' => array(
'eck__bundle__delete_form',
$entity_type,
$bundle,
),
'access arguments' => array(
"delete {$entity_type->name} {$bundle->name} bundle",
),
'file' => 'eck.bundle.inc',
);
//The entity autocomplete module does a great job at providing generalize
//autocomplete function that will work for any entity that declares the label
//property in the entity_info array, but there is not a general solution to
//have autocomplete functionality from a field. So I will fill that gap by
//declaring a field_autocomplete for all eck entities
$menu["admin/structure/eck/{$entity_type->name}/{$bundle->name}/field-autocomplete"] = array(
'title' => "Field Autocomplete for {$entity_type->name}:{$bundle->name}",
'page callback' => "eck__bundle__field_autocomplete",
'page arguments' => array(
$entity_type,
$bundle,
),
'access arguments' => array(
"autocomplete {$entity_type->name} {$bundle->name} bundle",
),
'file' => 'eck.bundle.inc',
);
$admin_info = get_bundle_admin_info($entity_type->name, $bundle->name);
// OVERVIEW Entity
$menu[$admin_info['path']] = array(
'title' => "{$bundle->label} Entities",
'description' => "View all entites of type {$entity_type->label} with bundle {$bundle->label}",
'page callback' => "eck__entity__overview",
'page arguments' => array(
$entity_type,
$bundle,
),
'access arguments' => array(
"administer {$entity_type->name} {$bundle->name} entities",
),
'weight' => 0,
'file' => 'eck.entity.inc',
);
$menu[$admin_info['path'] . "/overview"] = array(
'title' => "Overview",
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
$crud_info = get_bundle_crud_info($entity_type->name, $bundle->name);
foreach ($crud_info as $action => $info) {
$action_label = ucfirst($action);
$args = array();
if (array_key_exists('entity_id', $info)) {
$args[] = $info['entity_id'];
}
$args = array_merge(array(
$entity_type,
$bundle,
), $args);
$menu[$info['path']] = array(
'title' => "{$action_label} {$bundle->label} Entity",
'description' => "{$action_label} an entity of type {$entity_type->label} with bundle {$bundle->label}",
'page callback' => "eck__entity__{$action}",
'page arguments' => $args,
'access arguments' => array(
"{$action} {$entity_type->name} {$bundle->name} entities",
),
'file' => 'eck.entity.inc',
);
}
//dpm($menu, "Menu");
return $menu;
}