/**
  * {@inheritdoc}
  */
 public function getCurrentRouteMenuTreeParameters($menu_name)
 {
     $active_trail = $this->menuActiveTrail->getActiveTrailIds($menu_name);
     $parameters = new MenuTreeParameters();
     $parameters->setActiveTrail($active_trail)->addExpandedParents($active_trail)->addExpandedParents($this->treeStorage->getExpanded($menu_name, $active_trail));
     return $parameters;
 }
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $items = [];
     $current_id = $this->active->getActiveLink('main')->getPluginId();
     while (!empty($current_id)) {
         $current_link = $this->linkManager->createInstance($current_id);
         /** @var MenuLinkContent $current_link */
         $link = new Link($current_link->getTitle(), $current_link->getUrlObject());
         $items[] = $link;
         $current_id = $current_link->getParent();
     }
     $breadcrumbs = new Breadcrumb();
     $breadcrumbs->setLinks(array_reverse($items));
     return $breadcrumbs->toRenderable();
 }
 /**
  * Loads the contents of a menu block.
  *
  * This function is often a destination for these blocks.
  * For example, 'admin/structure/types' needs to have a destination to be
  * valid in the Drupal menu system, but too much information there might be
  * hidden, so we supply the contents of the block.
  *
  * @return array
  *   A render array suitable for drupal_render.
  */
 public function getBlockContents()
 {
     // We hard-code the menu name here since otherwise a link in the tools menu
     // or elsewhere could give us a blank block.
     $link = $this->menuActiveTrail->getActiveLink('admin');
     if ($link && ($content = $this->getAdminBlock($link))) {
         $output = array('#theme' => 'admin_block_content', '#content' => $content);
     } else {
         $output = array('#markup' => t('You do not have any administrative items.'));
     }
     return $output;
 }
 /**
  * {@inheritdoc}
  */
 public function getCurrentRouteMenuTreeParameters($menu_name)
 {
     $route_parameters = $this->routeMatch->getRawParameters()->all();
     ksort($route_parameters);
     $cid = 'current-route-parameters:' . $menu_name . ':route:' . $this->routeMatch->getRouteName() . ':route_parameters:' . serialize($route_parameters);
     if (!isset($this->cachedCurrentRouteParameters[$menu_name])) {
         $cache = $this->cache->get($cid);
         if ($cache && $cache->data) {
             $parameters = $cache->data;
         } else {
             $active_trail = $this->menuActiveTrail->getActiveTrailIds($menu_name);
             $parameters = new MenuTreeParameters();
             $parameters->setActiveTrail($active_trail)->addExpandedParents($active_trail)->addExpandedParents($this->treeStorage->getExpanded($menu_name, $active_trail));
             $this->cache->set($cid, $parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name));
         }
         $this->cachedCurrentRouteParameters[$menu_name] = $parameters;
     }
     return $this->cachedCurrentRouteParameters[$menu_name];
 }
 /**
  * {@inheritdoc}
  */
 public function getCacheKeys()
 {
     // Add a key for the active menu trail.
     $menu = $this->getDerivativeId();
     return array_merge(parent::getCacheKeys(), array($this->menuActiveTrail->getActiveTrailCacheKey($menu)));
 }