protected function EntityMenuLinkController::attachLoad in Entity menu links 7
Attaches data to entities upon loading.
This will attach fields, if the entity is fieldable. It calls hook_entity_load() for modules which need to add data to all entities. It also calls hook_TYPE_load() on the loaded entities. For example hook_node_load() or hook_user_load(). If your hook_TYPE_load() expects special parameters apart from the queried entities, you can set $this->hookLoadArguments prior to calling the method. See NodeController::attachLoad() for an example.
Parameters
$queried_entities: Associative array of query results, keyed on the entity ID.
$revision_id: ID of the revision that was loaded, or FALSE if the most current revision was loaded.
Overrides DrupalDefaultEntityController::attachLoad
File
- ./
entity_menu_links.controller.inc, line 18
Class
- EntityMenuLinkController
- Controller class for menu links.
Code
protected function attachLoad(&$menu_links, $revision_id = FALSE) {
foreach ($menu_links as $mlid => &$item) {
$item = (array) $item;
$item['options'] = unserialize($item['options']);
if ($item['external']) {
$item['access'] = TRUE;
$map = array();
$item['href'] = $item['link_path'];
$item['title'] = $item['link_title'];
$item['localized_options'] = $item['options'];
}
else {
$map = explode('/', $item['link_path']);
if (!empty($item['to_arg_functions'])) {
_menu_link_map_translate($map, $item['to_arg_functions']);
}
$item['href'] = implode('/', $map);
// Note - skip callbacks without real values for their arguments.
if (strpos($item['href'], '%') !== FALSE) {
$item['access'] = FALSE;
}
// menu_tree_check_access() may set this ahead of time for links to nodes.
if (!isset($item['access'])) {
if (!empty($item['load_functions']) && !_menu_load_objects($item, $map)) {
// An error occurred loading an object.
$item['access'] = FALSE;
$item = (object) $item;
continue;
}
_menu_check_access($item, $map);
}
// For performance, don't localize a link the user can't access.
if ($item['access']) {
_menu_item_localize($item, $map, TRUE);
}
}
// Allow other customizations - e.g. adding a page-specific query string to the
// options array. For performance reasons we only invoke this hook if the link
// has the 'alter' flag set in the options array.
if (!empty($item['options']['alter'])) {
drupal_alter('translated_menu_link', $item, $map);
}
$item = (object) $item;
}
parent::attachLoad($menu_links, $revision_id);
}