public function testSchemeRedirect()
 {
     $coll = new RouteCollection();
     $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https')));
     $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext());
     $this->assertEquals(array('_route' => 'foo'), $matcher->match('/foo'));
 }
 public function testSchemeRedirect()
 {
     $coll = new RouteCollection();
     $coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https')));
     $matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext());
     $this->assertEquals(array('_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', 'path' => '/foo', 'permanent' => true, 'scheme' => 'https', 'httpPort' => $context->getHttpPort(), 'httpsPort' => $context->getHttpsPort(), '_route' => 'foo'), $matcher->match('/foo'));
 }
예제 #3
0
 /**
  * Redirects the user to another URL.
  *
  * @param string $path   The path info to redirect to.
  * @param string $route  The route that matched
  * @param string $scheme The URL scheme (null to keep the current one)
  *
  * @return array An array of parameters
  */
 public function redirect($path, $route, $scheme = null)
 {
     $array = parent::redirect($path, $route, $scheme);
     // Make sure that the kernel knows how to properly handle this route
     $array['_defaultHandler'] = true;
     return $array;
 }
예제 #4
0
 public function redirect($path, $route, $scheme = null, $logPath = null)
 {
     if ($logPath) {
         $logger = new Logger('redirect');
         $logger->pushHandler(new StreamHandler($logPath, Logger::INFO));
         $logger->addInfo('redirect', ['url' => $this->context->getPathInfo() . '?' . $this->context->getQueryString(), 'location' => $path, 'method' => $this->context->getMethod()]);
     }
     return parent::redirect($path, $route, $scheme);
 }
 /**
  * Tries to match a URL path with a set of routes.
  *
  * If the matcher can not find information, it must throw one of the exceptions documented
  * below.
  *
  * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded)
  *
  * @return array An array of parameters
  *
  * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException If the resource could not be found
  * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException If the resource was found but the request method is not allowed
  *
  * @api
  */
 public function match($pathinfo)
 {
     $urlMatcher = new RedirectableUrlMatcher($this->getRouteCollection(), $this->getContext());
     $result = $urlMatcher->match($pathinfo);
     return $result;
 }