public function UltimenuManager::preRenderBuild in Ultimenu 8.2
Builds the Ultimenu outputs as a structured array ready for ::renderer().
File
- src/
UltimenuManager.php, line 200
Class
- UltimenuManager
- Implements UltimenuManagerInterface.
Namespace
Drupal\ultimenuCode
public function preRenderBuild(array $element) {
$build = $element['#build'];
$config = $build['config'];
unset($build, $element['#build']);
$config['current_path'] = Url::fromRoute('<current>')
->toString();
$goodies = $this
->getSetting('goodies');
$tree_access_cacheability = new CacheableMetadata();
$tree_link_cacheability = new CacheableMetadata();
$items = $this
->buildMenuTree($config, $tree_access_cacheability, $tree_link_cacheability);
// Apply the tree-wide gathered access cacheability metadata and link
// cacheability metadata to the render array. This ensures that the
// rendered menu is varied by the cache contexts that the access results
// and (dynamic) links depended upon, and invalidated by the cache tags
// that may change the values of the access results and links.
$tree_cacheability = $tree_access_cacheability
->merge($tree_link_cacheability);
$tree_cacheability
->applyTo($element);
// Build the elements.
$element['#config'] = $config;
$element['#items'] = $items;
$element['#attached'] = $this
->attach($config);
$element['#cache']['tags'][] = 'config:ultimenu.' . $config['menu_name'];
return $element;
}