4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing\Matcher
;
14 use Symfony\Component\Routing\Exception\ResourceNotFoundException
;
15 use Symfony\Component\Routing\Route
;
18 * @author Fabien Potencier <fabien@symfony.com>
22 abstract class RedirectableUrlMatcher
extends UrlMatcher
implements RedirectableUrlMatcherInterface
27 public function match($pathinfo)
30 $parameters = parent
::match($pathinfo);
31 } catch (ResourceNotFoundException
$e) {
32 if ('/' === substr($pathinfo, -1) || !in_array($this->context
->getMethod(), array('HEAD', 'GET'))) {
37 parent
::match($pathinfo.'/');
39 return $this->redirect($pathinfo.'/', null);
40 } catch (ResourceNotFoundException
$e2) {
51 protected function handleRouteRequirements($pathinfo, $name, Route
$route)
53 // check HTTP scheme requirement
54 $scheme = $route->getRequirement('_scheme');
55 if ($scheme && $this->context
->getScheme() !== $scheme) {
56 return array(self
::ROUTE_MATCH
, $this->redirect($pathinfo, $name, $scheme));
59 return array(self
::REQUIREMENT_MATCH
, null);