Beispiel #1
0
 /**
  * Routes the urls 
  *
  * @param InterfaceRequest $pRequest
  */
 public function route(InterfaceRequest $pRequest)
 {
     // getting the path info
     $uri = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
     // create empty parameters (none found so far)
     $params = array();
     // try to match all the routes to the uri
     foreach ($this->objRouteQueue as $route) {
         // get params if route is found
         $params = $route->match($uri);
         // if params are found, process them
         if (is_array($params) === true) {
             // load params into the request
             foreach ($params as $key => $value) {
                 // add key & value
                 $pRequest->setParam($key, $value);
             }
             // don't match other routes
             break;
         }
     }
     // return params
     return $params;
 }
Beispiel #2
0
 /**
  * Checks if a view exists in the DI container
  * 
  * @param InterfaceRequest $pRequest
  * @return boolean
  */
 protected function viewExists(InterfaceRequest $pRequest)
 {
     // build view id: <module>.view.<controller>.<action>
     $viewId = sprintf('%s.view.%s.%s', strtolower($pRequest->getParam('module', $this->getDefaultModule())), strtolower($pRequest->getParam('controller', $this->getDefaultController())), strtolower($pRequest->getParam('action', $this->getDefaultAction())));
     // load view
     return $this->getDiContainer()->definitionExists($viewId);
 }