コード例 #1
0
ファイル: route.php プロジェクト: markzero/wp-on-routes
 public static function filter_by_request()
 {
     $routes = Main::get_instance()->routes;
     if (!$routes) {
         return;
     }
     return \_u::find($routes, function ($route) {
         return $route->method->equalsCurrent() && ($route->path->equalsCurrent() || $route->path->matchParams()) && Agent::matchesCurrent($route->agent);
     });
 }
コード例 #2
0
ファイル: headers.php プロジェクト: markzero/wp-on-routes
 public function set_all()
 {
     foreach ($this->names as $header => $value) {
         if (strtolower($header) == 'exclude') {
             \_u::each($value, function ($v, $i) {
                 header_remove($v);
             });
         } else {
             header($header . ': ' . $value);
         }
     }
 }
コード例 #3
0
ファイル: agent.php プロジェクト: markzero/wp-on-routes
 public static function matchesCurrent($agent)
 {
     // if user did not specify agent, return like it's found
     if (!isset($agent)) {
         return true;
     }
     $real_agent = Main::get_instance()->current_request->real_agent;
     if (is_array($agent)) {
         return \_u::any($agent, function ($agt) use($real_agent) {
             return preg_match($agt->value, $real_agent);
         });
     } else {
         return preg_match($agent->value, $real_agent);
     }
 }
コード例 #4
0
ファイル: main.php プロジェクト: markzero/wp-on-routes
 public function add_routes()
 {
     $routes = func_get_args();
     \_u::each($routes, function ($route, $index) {
         $method = key($route);
         $items = $route[$method];
         if (!Method::has_method(strtolower($method))) {
             continue;
         }
         $route = new Route($items);
         $route->method = new Method($method);
         if (isset($items['headers']) && is_array($items['headers'])) {
             $route->headers = Headers::set_for_route($items['headers']);
         }
         $this->routes[] = $route;
     });
 }
コード例 #5
0
ファイル: underscore.php プロジェクト: markzero/wp-on-routes
 public function getInstance()
 {
     if (!isset(self::$_instance)) {
         $c = __CLASS__;
         self::$_instance = new $c();
     }
     return self::$_instance;
 }
コード例 #6
0
ファイル: path.php プロジェクト: markzero/wp-on-routes
 /**
  * Set $_GET params.
  */
 public function set_params_gets()
 {
     \_u::each($this->params, function ($param, $index) {
         $_GET[$index] = $param;
     });
 }