Example #1
0
 /**
  * Tries to match the current route against the request
  *
  * @param \Feedr\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;
 }
Example #2
0
 /**
  * Updates a new feed
  *
  * @param int                             $feedId       The feed ID
  * @param \Feedr\Network\Http\RequestData $request      The request
  * @param \Feedr\Auth\User                $user         The user
  * @param \Feedr\Storage\Database\Auth    $authDatabase The auth database handler
  */
 public function update($feedId, RequestData $request, User $user, Auth $authDatabase)
 {
     $repos = json_decode($request->post('repos'), true);
     $admins = json_decode($request->post('admins'), true);
     $this->updateRepositories($feedId, $repos);
     $this->createAdmins($admins, $authDatabase);
     $this->updateAdmins($feedId, $admins);
     $stmt = $this->dbConnection->prepare('UPDATE feeds SET name = :name WHERE id = :feedID');
     $stmt->execute(['name' => $request->post('name'), 'feedID' => $feedId]);
     $this->log('updateFeed', new \DateTime(), $user->get('id'), $feedId);
 }
Example #3
0
 /**
  * Gets the route for he current request
  *
  * @param \Feedr\Network\Http\RequestData $request The request data
  *
  * @return \Feedr\Router\Route\AccessPoint          The matching route
  * @throws \Feedr\Router\UnsupportedMethodException When the request contains an unsupported method
  * @throws \Feedr\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) {
         /** @var \Feedr\Router\Route\AccessPoint $route */
         if ($route->matchesRequest($request)) {
             return $route;
         }
     }
     throw new NotFoundException('No route matches the request.');
 }