This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Components/Routing/Matcher/ApacheUrlMatcher.php

69 lines
1.7 KiB
PHP
Raw Normal View History

2010-02-17 13:53:31 +00:00
<?php
namespace Symfony\Components\Routing\Matcher;
use Symfony\Components\Routing\Route;
use Symfony\Components\Routing\RouteCollection;
/*
* This file is part of the Symfony framework.
2010-02-17 13:53:31 +00:00
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* ApacheUrlMatcher matches URL based on Apache mod_rewrite matching (see ApacheMatcherDumper).
*
* @package Symfony
* @subpackage Components_Routing
2010-02-17 13:53:31 +00:00
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ApacheUrlMatcher extends UrlMatcher
{
protected $defaults;
protected $context;
2010-02-17 13:53:31 +00:00
/**
* Constructor.
*
* @param array $context The context
* @param array $defaults The default values
*/
public function __construct(array $context = array(), array $defaults = array())
2010-02-17 13:53:31 +00:00
{
$this->context = $context;
$this->defaults = $defaults;
2010-02-17 13:53:31 +00:00
}
/**
* Tries to match a URL based on Apache mod_rewrite matching.
*
* Returns false if no route matches the URL.
*
* @param string $url URL to be parsed
*
* @return array|false An array of parameters or false if no route matches
*/
public function match($url)
2010-02-17 13:53:31 +00:00
{
if (!isset($_SERVER['_ROUTING__route'])) {
// fall-back to the default UrlMatcher
return parent::match($url);
}
2010-02-17 13:53:31 +00:00
$parameters = array();
foreach ($_SERVER as $key => $value) {
if ('_ROUTING_' === substr($key, 0, 9))
{
$parameters[substr($key, 9)] = $value;
unset($_SERVER[$key]);
}
}
return $parameters;
}
2010-02-17 13:53:31 +00:00
}