getCachedResolvedUriPath() публичный Метод

Checks the cache for the given route values and returns the cached resolvedUriPath if a cache entry is found
public getCachedResolvedUriPath ( array $routeValues ) : string | boolean
$routeValues array
Результат string | boolean the cached request path or FALSE if no cache entry was found
 /**
  * @test
  */
 public function getCachedResolvedUriPathSkipsCacheIfRouteValuesContainObjectsThatCantBeConvertedToHashes()
 {
     $mockObject = new \stdClass();
     $routeValues = ['b' => 'route values', 'someObject' => $mockObject];
     $this->mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($mockObject)->will($this->returnValue(null));
     $this->mockResolveCache->expects($this->never())->method('has');
     $this->mockResolveCache->expects($this->never())->method('set');
     $this->routerCachingService->getCachedResolvedUriPath($routeValues);
 }
Пример #2
0
 /**
  * Builds the corresponding uri (excluding protocol and host) by iterating
  * through all configured routes and calling their respective resolves()
  * method. If no matching route is found, an empty string is returned.
  * Note: calls of this message are cached by RouterCachingAspect
  *
  * @param array $routeValues Key/value pairs to be resolved. E.g. array('@package' => 'MyPackage', '@controller' => 'MyController');
  * @return string
  * @throws NoMatchingRouteException
  */
 public function resolve(array $routeValues)
 {
     $cachedResolvedUriPath = $this->routerCachingService->getCachedResolvedUriPath($routeValues);
     if ($cachedResolvedUriPath !== false) {
         return $cachedResolvedUriPath;
     }
     $this->lastResolvedRoute = null;
     $this->createRoutesFromConfiguration();
     /** @var $route Route */
     foreach ($this->routes as $route) {
         if ($route->resolves($routeValues)) {
             $this->lastResolvedRoute = $route;
             $resolvedUriPath = $route->getResolvedUriPath();
             if ($resolvedUriPath !== null) {
                 $this->routerCachingService->storeResolvedUriPath($resolvedUriPath, $routeValues);
             }
             return $resolvedUriPath;
         }
     }
     $this->systemLogger->log('Router resolve(): Could not resolve a route for building an URI for the given route values.', LOG_WARNING, $routeValues);
     throw new NoMatchingRouteException('Could not resolve a route and its corresponding URI for the given parameters. This may be due to referring to a not existing package / controller / action while building a link or URI. Refer to log and check the backtrace for more details.', 1301610453);
 }