public function getMenus()
{
$menus = elgg_get_config('menus');
// get JIT menu items
// note that 'river' is absent from this list - hooks attempt to get object/subject entities cause problems
$jit_menus = array('annotation', 'entity', 'login', 'longtext', 'owner_block', 'user_hover', 'widget');
// create generic ElggEntity, ElggAnnotation, ElggUser, ElggWidget
$annotation = new \ElggAnnotation();
$annotation->id = 999;
$annotation->name = 'generic_comment';
$annotation->value = 'testvalue';
$entity = new \ElggObject();
$entity->guid = 999;
$entity->subtype = 'blog';
$entity->title = 'test entity';
$entity->access_id = ACCESS_PUBLIC;
$user = new \ElggUser();
$user->guid = 999;
$user->name = "Test User";
$user->username = 'test_user';
$widget = new \ElggWidget();
$widget->guid = 999;
$widget->title = 'test widget';
// call plugin hooks
foreach ($jit_menus as $type) {
$params = array('entity' => $entity, 'annotation' => $annotation, 'user' => $user);
switch ($type) {
case 'owner_block':
case 'user_hover':
$params['entity'] = $user;
break;
case 'widget':
// this does not work because you cannot set a guid on an entity
$params['entity'] = $widget;
break;
case 'longtext':
$params['id'] = rand();
break;
default:
break;
}
$menus[$type] = elgg_trigger_plugin_hook('register', "menu:{$type}", $params, array());
}
// put the menus in tree form for inspection
$tree = array();
foreach ($menus as $menu_name => $attributes) {
foreach ($attributes as $item) {
/* @var \ElggMenuItem $item */
$name = $item->getName();
$text = htmlspecialchars($item->getText(), ENT_QUOTES, 'UTF-8', false);
$href = $item->getHref();
if ($href === false) {
$href = 'not a link';
} elseif ($href === "") {
$href = 'not a direct link - possibly ajax';
}
$section = $item->getSection();
$parent = $item->getParentName();
if (!$parent) {
$parent = 'none';
}
$tree[$menu_name][$name] = array("text: {$text}", "href: {$href}", "section: {$section}", "parent: {$parent}");
}
}
ksort($tree);
return $tree;
}