From 839782b6e4a7c22d531e065a9867cec661892d31 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 5 Apr 2011 15:14:06 +0200 Subject: [PATCH] [FrameworkBundle] added support for routing redirection --- .../Resources/config/routing.xml | 4 +-- .../Routing/RedirectableUrlMatcher.php | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml index e14491eb6d..b021168a48 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml @@ -16,8 +16,8 @@ Symfony\Component\Routing\Generator\UrlGenerator Symfony\Component\Routing\Generator\UrlGenerator Symfony\Component\Routing\Generator\Dumper\PhpGeneratorDumper - Symfony\Component\Routing\Matcher\UrlMatcher - Symfony\Component\Routing\Matcher\UrlMatcher + Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher + Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer %kernel.name%%kernel.environment%UrlMatcher diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php b/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php new file mode 100644 index 0000000000..54b65ce1ce --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\Routing; + +use Symfony\Component\Routing\Matcher\UrlMatcher; +use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; + +/** + * @author Fabien Potencier + */ +class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface +{ + public function redirect($pathinfo, $route) + { + return array( + '_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction', + 'url' => $this->context['base_url'].$pathinfo, + 'permanent' => true, + '_route' => $route, + ); + } +}