/** * Handle a a set of routes: if a match is found, execute the relating handling function * @param array $routes Collection of route patterns and their handling functions * @throws InvalidParameter * @return \Neuron\Net\Response The response */ private function handle($routes) { // The current page URL $numHandled = 0; // Loop all routes foreach ($routes as $route) { if (!$route instanceof Route) { throw new InvalidParameter("Route contains invalid models."); } // we have a match! if ($params = $this->request->parseRoute($route)) { if (!is_array($params)) { $params = array(); } // call the handling function with the URL parameters $this->handleMatch($route, $params); //call_user_func_array($route['fn'], $params); // yay! $numHandled++; // If we need to quit, then quit //if ($quitAfterRun) break; } } return $numHandled; }