getRequestType() public static method

public static getRequestType ( )
示例#1
0
文件: Router.php 项目: letsdrink/ouzo
 /**
  * @return RouteRule
  * @throws RouterException
  */
 public function findRoute()
 {
     $path = $this->uri->getPathWithoutPrefix();
     $requestType = Uri::getRequestType();
     $rule = $this->findRouteRule($path, $requestType);
     if (!$rule) {
         throw new RouterException('No route rule found for HTTP method [' . $requestType . '] and URI [' . $path . ']');
     }
     $rule->setParameters($path);
     return $rule;
 }
示例#2
0
 public static function protect(Controller $controller)
 {
     $controller->before[] = function () {
         if (CsrfProtector::isMethodProtected(Uri::getRequestType())) {
             CsrfProtector::validate();
         }
         return true;
     };
     $controller->after[] = function () use($controller) {
         $controller->setCookie(array('name' => 'csrftoken', 'value' => CsrfProtector::getCsrfToken(), 'expire' => 0, 'path' => '/'));
         return true;
     };
 }