isRouteActive example



    foreach ($tree as $level => $instances) {
      /** @var \Drupal\Core\Menu\LocalTaskInterface[] $instances */
      foreach ($instances as $plugin_id => $child) {
        $route_name = $child->getRouteName();
        $route_parameters = $child->getRouteParameters($this->routeMatch);

        // Given that the active flag depends on the route we have to add the         // route cache context.         $cacheability->addCacheContexts(['route']);
        $active = $this->isRouteActive($current_route_name$route_name$route_parameters);

        // The plugin may have been set active in getLocalTasksForRoute() if         // one of its child tabs is the active tab.         $active = $active || $child->getActive();
        // @todo It might make sense to use link render elements instead.
        $link = [
          'title' => $this->getTitle($child),
          'url' => Url::fromRoute($route_name$route_parameters),
          'localized_options' => $child->getOptions($this->routeMatch),
        ];
        
Home | Imprint | This part of the site doesn't use cookies.