Exemplo n.º 1
0
 /**
  * loads controller class
  *
  * @throws HttpKernelException
  * @return string
  */
 protected function loadControllerClass()
 {
     $moduleName = $this->request->getModuleName();
     $controllerName = $this->request->getControllerName();
     // fully qualified controller class name
     $fullQualifiedClassName = $this->getControllerClassName($moduleName, $controllerName);
     // load controller class
     if (!class_exists($fullQualifiedClassName, false)) {
         // relative controller class name (without namespace)
         $posLastBackslash = strrpos($fullQualifiedClassName, '\\');
         // class name
         $className = substr($fullQualifiedClassName, $posLastBackslash + 1);
         // path to controller classes for that module
         $controllerPath = $this->getControllerPath($moduleName, $controllerName);
         // controller class file
         $classFile = $controllerPath . DIRECTORY_SEPARATOR . $className . '.php';
         if (!is_file($classFile)) {
             throw new HttpKernelException("Could not find file '{$classFile}' for class '{$fullQualifiedClassName}'!");
         }
         /** @noinspection PhpIncludeInspection */
         require_once $classFile;
     }
     return $fullQualifiedClassName;
 }
Exemplo n.º 2
0
 /**
  * @param  RequestInterface $request
  * @return string
  */
 protected function getRequestUriWithoutQueryString(RequestInterface $request)
 {
     $requestUri = $request->getRequestUri();
     if (false !== ($pos = strpos($requestUri, '?'))) {
         $requestUri = substr($requestUri, 0, $pos);
     }
     return $requestUri;
 }
Exemplo n.º 3
0
 /**
  * gets action method
  *
  * @return string
  */
 public function getActionMethod()
 {
     $actionMethod = Util::getCamelCased($this->request->getActionName()) . 'Action';
     $actionMethod = lcfirst($actionMethod);
     return $actionMethod;
 }
Exemplo n.º 4
0
 /**
  * sets template path by request
  *
  * @param RequestInterface $request
  */
 public function setTemplatePathByRequest(RequestInterface $request)
 {
     $params = array('action' => $request->getActionName(), 'controller' => $request->getControllerName(), 'module' => $request->getModuleName());
     $templatePath = Util::parsePattern($this->viewPathPattern, $params);
     $this->getRenderer()->setTemplatePath($templatePath);
 }