コード例 #1
0
ファイル: GenericRoute.php プロジェクト: johnnyos/johnnyos
 /**
  * Check if request matches this route.
  *
  * @param Request $request Request to check against.
  * @return bool
  */
 public function match(Request $request) : bool
 {
     // use absolute path
     if ($this->flags & self::UseAbsolutePath) {
         $path = $request->getPath();
         // use relative path
     } else {
         $path = $request->getRelativePath();
     }
     return $this->path === rawurldecode($path);
 }
コード例 #2
0
ファイル: RegexRoute.php プロジェクト: johnnyos/johnnyos
 /**
  * Check if request matches this route.
  *
  * @param Request $request Request to check against.
  * @return bool
  */
 public function match(Request $request) : bool
 {
     // use absolute path
     if ($this->flags & self::UseAbsolutePath) {
         $path = $request->getPath();
         // use relative path
     } else {
         $path = $request->getRelativePath();
     }
     return (bool) preg_match(sprintf('/%s/', str_replace('/', '\\/', $this->path)), rawurldecode($path));
 }
コード例 #3
0
 /**
  * Creates a Controller instance.
  *
  * @param Request $request Request data.
  * @param Response $response Response data.
  */
 public function __construct(Request $request, Response $response)
 {
     // split up request path
     $path = explode('/', trim($request->getRelativePath(), '/'));
     // first item is action
     $action = array_shift($path);
     // set action if not empty
     if (empty($action) === false) {
         $this->setAction($action);
     }
     $this->setParameters((array) $path)->execute($request, $response);
 }