Commit 8b6f476a authored by Fabien Potencier's avatar Fabien Potencier

updated Routing component

parent 5f356927
...@@ -27,6 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher; ...@@ -27,6 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection; use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException; use Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Matcher\Exception\NotFoundException; use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
use Symfony\Component\ClassLoader\UniversalClassLoader; use Symfony\Component\ClassLoader\UniversalClassLoader;
...@@ -310,16 +311,17 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -310,16 +311,17 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
public function onCoreRequest(KernelEvent $event) public function onCoreRequest(KernelEvent $event)
{ {
$this['request'] = $event->getRequest(); $this['request'] = $event->getRequest();
$this['request_context'] = new RequestContext(
$this['request']->getBaseUrl(),
$this['request']->getMethod(),
$this['request']->getHost(),
$this['request']->getPort(),
$this['request']->getScheme()
);
$this['controllers']->flush(); $this['controllers']->flush();
$matcher = new RedirectableUrlMatcher($this['routes'], array( $matcher = new RedirectableUrlMatcher($this['routes'], $this['request_context']);
'base_url' => $this['request']->getBaseUrl(),
'method' => $this['request']->getMethod(),
'host' => $this['request']->getHost(),
'port' => $this['request']->getPort(),
'is_secure' => $this['request']->isSecure(),
));
$this['dispatcher']->dispatch(Events::onSilexBefore); $this['dispatcher']->dispatch(Events::onSilexBefore);
......
...@@ -22,13 +22,8 @@ class UrlGeneratorExtension implements ExtensionInterface ...@@ -22,13 +22,8 @@ class UrlGeneratorExtension implements ExtensionInterface
{ {
$app['url_generator'] = $app->share(function() use ($app) { $app['url_generator'] = $app->share(function() use ($app) {
$app->flush(); $app->flush();
return new UrlGenerator($app['routes'], array(
'base_url' => $app['request']->getBaseUrl(), return new UrlGenerator($app['routes'], $app['request_context']);
'method' => $app['request']->getMethod(),
'host' => $app['request']->getHost(),
'port' => $app['request']->getPort(),
'is_secure' => $app['request']->isSecure(),
));
}); });
} }
} }
...@@ -53,11 +53,11 @@ class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatche ...@@ -53,11 +53,11 @@ class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatche
/** /**
* @see RedirectableUrlMatcherInterface::match() * @see RedirectableUrlMatcherInterface::match()
*/ */
public function redirect($pathinfo, $route) public function redirect($path, $route, $scheme = null)
{ {
return array( return array(
'_controller' => function ($url) { return new RedirectResponse($url, 301); }, '_controller' => function ($url) { return new RedirectResponse($url, 301); },
'url' => $this->context['base_url'].$pathinfo, 'url' => $this->context->getBaseUrl().$path,
); );
} }
} }
Subproject commit 46538dba17851bd3b1815cf89076838121b443a2 Subproject commit 1740f71d38056f317b655bdab09e4a666f5bf65b
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment