public function loadTreeData($menu_name, MenuTreeParameters
$parameters) { $tree_cid = "tree-data:
$menu_name:" .
serialize($parameters);
$cache =
$this->menuCacheBackend->
get($tree_cid);
if ($cache &&
isset($cache->data
)) { $data =
$cache->data;
// Cache the definitions in memory so they don't need to be loaded again.
$this->definitions +=
$data['definitions'
];
unset($data['definitions'
]);
} else { $links =
$this->
loadLinks($menu_name,
$parameters);
$data['tree'
] =
$this->
doBuildTreeData($links,
$parameters->activeTrail,
$parameters->minDepth
);
$data['definitions'
] =
[];
$data['route_names'
] =
$this->
collectRoutesAndDefinitions($data['tree'
],
$data['definitions'
]);
$this->menuCacheBackend->
set($tree_cid,
$data, Cache::PERMANENT,
['config:system.menu.' .
$menu_name]);
// The definitions were already added to $this->definitions in
// $this->doBuildTreeData()
unset($data['definitions'
]);
} return $data;
} /**
* Loads links in the given menu, according to the given tree parameters.
*
* @param string $menu_name
* A menu name.
* @param \Drupal\Core\Menu\MenuTreeParameters $parameters
* The parameters to determine which menu links to be loaded into a tree.
* This method will set the absolute minimum depth, which is used in
* MenuTreeStorage::doBuildTreeData().
*
* @return array
* A flat array of menu links that are part of the menu. Each array element
* is an associative array of information about the menu link, containing
* the fields from the {menu_tree} table. This array must be ordered
* depth-first.
*/