Ejemplo n.º 1
0
 /**
  * Sets the given params to the Request.
  *
  * @param array $params   The params to request.
  */
 protected function setParamsToRequest(array $params)
 {
     foreach ($params as $name => $value) {
         if (is_numeric($name)) {
             continue;
         }
         $this->request->setParam($name, $value);
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns a controller and an action for the request's target.
  *
  * @param string $controller   $he controller class name. (Outgoing parameter)
  * @param string $action       The action name in the controller class. (Outgoing parameter)
  * @param string $uri          The uri to check. If not given, the current uri will be used.
  *
  * @return string   The controller and action separated by a '/' character.
  *
  * @throws \YapepBase\Exception\RouterException   On errors. (Including if the route is not found)
  */
 public function getRoute(&$controller = null, &$action = null, $uri = null)
 {
     $uri = empty($uri) ? $this->request->getTarget() : $uri;
     $target = explode('/', trim($uri, '/ '));
     $controller = array_shift($target);
     if (empty($controller)) {
         $controller = 'Index';
     } else {
         $controller = $this->convertPathPartToName($controller);
     }
     if (empty($target)) {
         $action = 'Index';
     } else {
         $action = $this->convertPathPartToName(array_shift($target));
     }
     foreach ($target as $key => $value) {
         $this->request->setParam($key, $value);
     }
     return $controller . '/' . $action;
 }