/** * Match url path, when a path is matched his script function is set. * * @param array $functions * @return Yasc_Router_Route */ public function match(array $functions = null) { if (null !== $functions) { $this->_functions = $functions; } if (null === $this->_functions) { throw new Yasc_Router_Exception("No user defined functions"); } foreach ($this->_functions as $function) { if (false === $function instanceof Yasc_Function) { throw new Yasc_Router_Exception("Function is not a instance of Yasc_Function"); } if ($this->_request->getMethod() != $function->getMethod()) { if ($this->_request->getMethod() == Yasc_Http_Request::METHOD_POST && isset($_POST["_method"])) { if (strtolower($_POST["_method"]) == $function->getMethod()) { if (true === $this->_lookup($function)) { $this->_requestedFunction = $function; break; } } continue; } continue; } else { if ($this->_request->getMethod() == Yasc_Http_Request::METHOD_POST && isset($_POST["_method"])) { if (strtolower($_POST["_method"]) == $function->getMethod()) { if (true === $this->_lookup($function)) { $this->_requestedFunction = $function; break; } } continue; } else { if (true === $this->_lookup($function)) { $this->_requestedFunction = $function; break; } } continue; } } if (null === $this->_requestedFunction) { throw new Yasc_Router_Exception("Requested function not found, `" . $this->_request->getUrl() . "` via `" . strtoupper($this->_request->getMethod()) . "`"); } $this->_requestedFunction->setParams((array) $this->_setupParams()); return $this; }