/** * @param Route $route * @param $params * @throws InvalidParameter */ private function handleMatch(Route $route, $params) { $function = $route->getFunction(); // Check for additional parameters foreach ($route->getParameters() as $v) { $params[] = $v; } // First handle the filters foreach ($route->getFilters() as $filter) { // Check if exist if (!isset($this->filters[$filter->getName()])) { throw new InvalidParameter("Filter " . $filter->getName() . " is not registered in the router."); } $filter->setRequest($this->request); $response = $filter->check($this->filters[$filter->getName()]); $filter->clearRequest(); // If output was not TRUE, handle the filter return value as output. if ($response !== true) { $this->output($response); return; } } if (is_callable($function)) { $response = call_user_func_array($function, $params); } else { if (strpos($function, '@')) { $param = explode('@', $function); if (count($param) !== 2) { throw new InvalidParameter("Controller@method syntax not valid for " . $function); } $response = $this->handleController($param[0], $param[1], $params, $route->getModule()); } else { throw new InvalidParameter("Method not found."); } } $this->output($response); }