/** * Binds the request to the form * * @param \PitchBlade\Network\Http\RequestData $request The request */ public function bind(RequestData $request) { foreach ($request->postIterator() as $name => $variable) { if (!array_key_exists($name, $this->fields)) { continue; } $this->fields[$name]->setRawValue($variable); } }
/** * Tries to match the current route against the request * * @param \PitchBlade\Network\Http\RequestData $request The request data * * @return boolean True when the route matches the request */ public function matchesRequest(RequestData $request) { $pathParts = explode('/', trim($request->getPath(), '/')); if (!$this->doesMatch($this->path->getParts(), $pathParts)) { return false; } $this->processVariables($this->path->getParts(), $pathParts); return true; }
/** * Gets the route for he current request * * @param \PitchBlade\Network\Http\RequestData $request The request data * * @return \PitchBlade\Router\AccessPoint The matching route * @throws \PitchBlade\Router\UnsupportedMethodException When the request contains an unspported method * @throws \PitchBlade\Router\NotFoundException When no route matches */ public function getRoute(RequestData $request) { if (!array_key_exists($request->getMethod(), $this->routes)) { throw new UnsupportedMethodException('The `' . $request->getMethod() . '` method is currently not implemented.'); } foreach ($this->routes[$request->getMethod()] as $route) { if ($route->matchesRequest($request)) { return $route; } } throw new NotFoundException('No route matches the request.'); }