storeResolvedUriPath() 공개 메소드

Stores the $uriPath in the cache together with the $routeValues
public storeResolvedUriPath ( string $uriPath, array $routeValues ) : void
$uriPath string
$routeValues array
리턴 void
 /**
  * @test
  */
 public function storeResolvedUriPathConvertsObjectsImplementingCacheAwareInterfaceToCacheEntryIdentifier()
 {
     $mockObject = $this->createMock(CacheAwareInterface::class);
     $mockObject->expects($this->atLeastOnce())->method('getCacheEntryIdentifier')->will($this->returnValue('objectIdentifier'));
     $routeValues = ['b' => 'route values', 'someObject' => $mockObject];
     $cacheIdentifier = '264b593d59582adea4ccc52b33cc093f';
     $matchingUriPath = 'uncached/matching/uri';
     $this->mockResolveCache->expects($this->once())->method('set')->with($cacheIdentifier, $matchingUriPath);
     $this->routerCachingService->storeResolvedUriPath($matchingUriPath, $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);
 }