public function testParametersMatches() { $ut = new UrlTools(); $regex = "#^/not-a-match/(?<id>\\d+)/(?<name>[^/]+)/junk\$#"; $url = "/not-a-match/123/barry/junk"; $params = array("id" => "123", "name" => "barry"); $this->assertEquals($params, $ut->parameters($regex, $url)); }
/** * Gathers custom parameters from a URL based on the conditions given by * the Controller. * * @param \Micro\ControllerInterface $controller * @param \Micro\Request $request * @return void */ protected function addParameters(ControllerInterface $controller, Request $request) { $regex = $this->ut->compile($controller->uri(), $controller->conditions()); $params = $this->ut->parameters($regex, $request->getPathInfo()); $request->request->add($params); }