public matchCurrentRequest ( ) |
public function matchCurrentRequest()
{
$requestMethod = isset($_POST['_method']) && ($_method = strtoupper($_POST['_method'])) && in_array($_method, array('PUT', 'DELETE')) ? $_method : $_SERVER['REQUEST_METHOD'];
$requestUrl = $_SERVER['REQUEST_URI'];
// strip GET variables from URL
if (($pos = strpos($requestUrl, '?')) !== false) {
$requestUrl = substr($requestUrl, 0, $pos);
}
return $this->match($requestUrl, $requestMethod);
}
public function testMatchRouterUsingBasePath() { $collection = new RouteCollection(); $collection->attach(new Route('/users/', array('_controller' => 'PHPRouter\\Test\\SomeController::usersCreate', 'methods' => 'GET'))); $router = new Router($collection); $router->setBasePath('/localhost/webroot'); foreach ($this->serverProvider() as $server) { $_SERVER = $server; self::assertTrue((bool) $router->matchCurrentRequest()); } }