Пример #1
0
 /**
  *
  */
 public function __construct()
 {
     /* Get HTTP method */
     $this->method = $_SERVER['REQUEST_METHOD'];
     /* Get requested query */
     $this->query = $_REQUEST['_QUERY'] != '/' ? $_REQUEST['_QUERY'] : 'main';
     /* Get path chunks */
     $this->path = explode('/', ltrim($this->query, '/'));
     /* Get HTTP passed params */
     $this->http_params = $_REQUEST;
     /* Get user address */
     $this->address = $this->getAddress();
     /* get CamelCase controller name */
     $this->controller = StringAssist::convertReference($this->path[0]);
 }
Пример #2
0
 /**
  * @param HttpRequest $request
  */
 public function __construct(HttpRequest $request)
 {
     /* Check for wrong 'listen' configuration */
     if (!is_array($this->listen)) {
         return false;
     }
     /* Get HTTP method */
     $this->method = $request->getMethod();
     /* Get HTTP params */
     $this->http_params = $request->getHttpParams();
     /* Get passed params */
     $passedParams = $request->getParams($this->matchControllerWithRequested($request));
     /* If no params was defined to listen */
     if ($this->listen === []) {
         /* If params were not passed */
         if ($passedParams === []) {
             /* Proxy to main action */
             $this->action = 'main';
         }
     } else {
         /* If params count same or less than we listening for */
         if (count($this->listen) >= count($passedParams)) {
             /* Define behaviour */
             $behaviour = $this->getBehaviour($passedParams);
             /* Set action */
             $this->action = $behaviour['action'] ? 'action' . StringAssist::convertReference($behaviour['action']) : 'main';
             /* Set params */
             $this->params = $behaviour['params'];
         }
     }
 }