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

updated Routing component

parent 5f356927
......@@ -27,6 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Matcher\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Matcher\Exception\NotFoundException;
use Symfony\Component\ClassLoader\UniversalClassLoader;
......@@ -310,16 +311,17 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
public function onCoreRequest(KernelEvent $event)
{
$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();
$matcher = new RedirectableUrlMatcher($this['routes'], array(
'base_url' => $this['request']->getBaseUrl(),
'method' => $this['request']->getMethod(),
'host' => $this['request']->getHost(),
'port' => $this['request']->getPort(),
'is_secure' => $this['request']->isSecure(),
));
$matcher = new RedirectableUrlMatcher($this['routes'], $this['request_context']);
$this['dispatcher']->dispatch(Events::onSilexBefore);
......
......@@ -22,13 +22,8 @@ class UrlGeneratorExtension implements ExtensionInterface
{
$app['url_generator'] = $app->share(function() use ($app) {
$app->flush();
return new UrlGenerator($app['routes'], array(
'base_url' => $app['request']->getBaseUrl(),
'method' => $app['request']->getMethod(),
'host' => $app['request']->getHost(),
'port' => $app['request']->getPort(),
'is_secure' => $app['request']->isSecure(),
));
return new UrlGenerator($app['routes'], $app['request_context']);
});
}
}
......@@ -53,11 +53,11 @@ class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatche
/**
* @see RedirectableUrlMatcherInterface::match()
*/
public function redirect($pathinfo, $route)
public function redirect($path, $route, $scheme = null)
{
return array(
'_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