예제 #1
0
 /**
  * Set BasePath
  *
  * @param string $basepath
  *   Request Base Path
  *
  * @return Next\HTTP\Request
  *   Request Object (Fluent Interface)
  */
 public function setBasepath($basepath)
 {
     $this->basepath = Tools::cleanAndInvertPath($basepath);
     return $this;
 }
예제 #2
0
 /**
  * Find the Template View File from FileSpec
  *
  * @return string
  *   Template View FilePath from defined FileSpec
  *
  * @see
  *   Next\Controller\Router\Router::getController()
  *   Next\Controller\Router\Router::getAction()
  */
 private function findFileBySpec()
 {
     // Known Replacements
     $application = $this->_application->getApplicationDirectory();
     $controller = $this->_application->getRouter()->getController();
     $action = $this->_application->getRouter()->getAction();
     /**
      * @internal
      * Finding Default SubPath
      *
      * Default SubPath is built by removing:
      *
      * - Application Directory,
      * - 'Controller' Keyword
      * - Controller ClassName
      *
      * from Controllers Name
      */
     $subpath = str_replace(array($application, self::CONTROLLERS_KEYWORD, basename($controller)), '', $controller);
     // Windows, Windows, Windows... <_<
     $subpath = str_replace('\\\\', '\\', $subpath);
     $subpath = trim($subpath, '\\');
     // Cleaning Controller Class to find its "Real Name"
     $controller = str_replace('Controller', '', basename($controller));
     // Cleaning known Action suffixes
     $action = str_replace(array(self::ACTION_METHOD_SUFFIX_VIEW, self::ACTION_METHOD_SUFFIX_ACTION), '', $action);
     // Replacing known matches
     $spec = trim(str_replace(array(self::APPLICATION, self::CONTROLLER, self::ACTION, self::SUBPATH), array($application, $controller, $action, $subpath), $this->_fileSpec), '/');
     $spec = Tools::cleanAndInvertPath($spec);
     return sprintf('%s.%s', strtolower($spec), $this->_extension);
 }