preLoadRoutes example

      $key = 'routing.non_admin_routes';
      if ($cache = $this->cache->get($key)) {
        $routes = $cache->data;
      }
      else {
        $routes = $this->state->get($key[]);
        $this->cache->set($key$routes, Cache::PERMANENT, ['routes']);
      }

      if ($routes) {
        // Preload all the non-admin routes at once.         $this->routeProvider->preLoadRoutes($routes);
      }
    }
  }

  /** * Alters existing routes for a specific collection. * * @param \Drupal\Core\Routing\RouteBuildEvent $event * The route build event. */
  public function onAlterRoutes(RouteBuildEvent $event) {
    
/** * {@inheritdoc} */
  public function getRouteByName($name) {
    return $this->getRouteProvider()->getRouteByName($name);
  }

  /** * {@inheritdoc} */
  public function preLoadRoutes($names) {
    return $this->getRouteProvider()->preLoadRoutes($names);
  }

  /** * {@inheritdoc} */
  public function getRoutesByNames($names) {
    return $this->getRouteProvider()->getRoutesByNames($names);
  }

  /** * {@inheritdoc} */

      }

      $this->serializedRoutes += $routes;
    }
  }

  /** * {@inheritdoc} */
  public function getRoutesByNames($names) {
    $this->preLoadRoutes($names);

    foreach ($names as $name) {
      // The specified route name might not exist or might be serialized.       if (!isset($this->routes[$name]) && isset($this->serializedRoutes[$name])) {
        $this->routes[$name] = unserialize($this->serializedRoutes[$name]);
        unset($this->serializedRoutes[$name]);
      }
    }

    return array_intersect_key($this->routes, array_flip($names));
  }

  
/** * {@inheritdoc} */
  public function getRouteByName($name) {
    return $this->lazyLoadItself()->getRouteByName($name);
  }

  /** * {@inheritdoc} */
  public function preLoadRoutes($names) {
    return $this->lazyLoadItself()->preLoadRoutes($names);
  }

  /** * {@inheritdoc} */
  public function getRoutesByNames($names) {
    return $this->lazyLoadItself()->getRoutesByNames($names);
  }

  /** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.