Пример #1
0
 public static function create()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #2
0
 public function getAnnotations()
 {
     if ($this->annotations === false) {
         $reader = Sabel_Annotation_Reader::create();
         $this->annotations = $reader->process($this->getDocComment());
     }
     return $this->annotations;
 }
Пример #3
0
 public function execute($bus)
 {
     $response = $bus->get("response");
     $status = $response->getStatus();
     if ($status->isFailure()) {
         return;
     }
     $controller = $bus->get("controller");
     $controller->mixin("Extroller_Mixin");
     $request = $bus->get("request");
     $gets = $request->fetchGetValues();
     $posts = $request->fetchPostValues();
     $params = $request->fetchParameterValues();
     $vCount = count($gets) + count($posts) + count($params);
     $values = array_merge($gets, $posts, $params);
     if (count($values) !== $vCount) {
         l("Extroller: request key overlaps", SBL_LOG_DEBUG);
         return $status->setCode(Sabel_Response::BAD_REQUEST);
     } else {
         foreach ($values as $name => $value) {
             $controller->setAttribute($name, $value);
         }
         $controller->setAttribute("REQUEST_VARS", $values);
         $controller->setAttribute("GET_VARS", $gets);
         $controller->setAttribute("POST_VARS", $posts);
     }
     $action = $bus->get("destination")->getAction();
     if ($controller->hasMethod($action)) {
         $reader = Sabel_Annotation_Reader::create();
         $annots = $reader->readMethodAnnotation($controller, $action);
         if (isset($annots["httpMethod"])) {
             $allows = $annots["httpMethod"][0];
             if (!$this->isMethodAllowed($request, $allows)) {
                 $response->setHeader("Allow", implode(",", array_map("strtoupper", $allows)));
                 return $status->setCode(Sabel_Response::METHOD_NOT_ALLOWED);
             }
         }
         if (isset($annots["check_client_id"])) {
             if (!$this->checkClientId($request, $bus->get("session"), $annots["check_client_id"][0])) {
                 return $status->setCode(Sabel_Response::BAD_REQUEST);
             }
         }
         if (isset($annots["check"]) && ($request->isGet() || $request->isPost())) {
             if (!($result = $this->validate($controller, $values, $request, $annots["check"]))) {
                 return $status->setCode(Sabel_Response::BAD_REQUEST);
             }
         }
     }
 }
Пример #4
0
 public function setUp()
 {
     $this->reader = Sabel_Annotation_Reader::create();
 }