/**
  * @throws ApplicationException
  * @throws \Exception
  */
 public function checkAnnotations()
 {
     $controllerName = explode(DIRECTORY_SEPARATOR, $this->controllerName);
     $actionName = array_pop($controllerName) . "/" . $this->actionName;
     $action = Scanner::getInstance()->getAction($actionName);
     if (!in_array($_SERVER['REQUEST_METHOD'], $action["methods"])) {
         throw new ApplicationException($_SERVER['REQUEST_METHOD'] . " is not allowed for the action!");
     }
     foreach ($action["annotations"] as $annotation => $val) {
         if ($val === "") {
             $annotationClass = new $annotation();
         } else {
             $annotationClass = new $annotation($val);
         }
         call_user_func_array([$annotationClass, "dispatch"], array());
     }
 }
Ejemplo n.º 2
0
 public function parseURI()
 {
     $uri = $_SERVER['REQUEST_URI'];
     $self = $_SERVER['PHP_SELF'];
     $index = basename($self);
     $directories = str_replace($index, '', $self);
     $requestString = str_replace($directories, '', $uri);
     $this->requestStr = $requestString;
     $requestParams = explode("/", $requestString);
     $this->controller = array_shift($requestParams);
     $this->action = array_shift($requestParams);
     $this->params = $requestParams;
     $this->customRoutes = Scanner::getInstance()->getCustomRoutes();
     if (!$this->searchCustomRoutes($requestParams)) {
         $this->actionNameAdjustment();
     }
     if ($_SERVER['REQUEST_METHOD'] === "POST") {
         $this->checkBindingModel();
     }
 }
 /**
  * @@Admin
  */
 public function api()
 {
     $actions = Scanner::getInstance()->getCustomRoutes();
     $viewModel = new AdminApiViewModel($actions);
     $this->renderDefaultLayout($viewModel);
 }