Exemple #1
0
 /**
  * @return string
  */
 public function getModulePath()
 {
     $sModulePath = $this->getPath();
     if (!SiteMapA::isValidMapPath($sModulePath) && SiteMapA::isValidObjectPath($sModulePath)) {
         $sModulePath = $this->getModuleMap()->getModulePath();
     }
     if (!UrlParserA::hasGoodTermination($sModulePath, DIRECTORY_SEPARATOR)) {
         $sModulePath .= DIRECTORY_SEPARATOR;
     }
     return $sModulePath;
 }
Exemple #2
0
 /**
  *
  * To allow a single controller type to return a different type of view
  * @param string|object $mView
  * @throws ExceptionPath
  */
 public function setView($mView)
 {
     if (ViewA::isValid($mView)) {
         $this->oView = $mView;
         $this->sViewPath = get_class($mView);
     } elseif (stristr(basename($mView), '.') === false && !is_file($mView)) {
         // namespaced class name
         $this->sViewPath = $mView;
     } elseif (SiteMapA::isValidObjectPath($mView)) {
         $this->sViewPath = $mView;
     } else {
         throw new ExceptionPath('View path [' . $mView . '] is not valid.');
     }
 }
Exemple #3
0
 /**
  *
  * @param string $sRegex
  * @param string $sPath
  * @throws ExceptionController
  * @throws ExceptionSitemap
  * @returns ControllerMap
  */
 public function mapController($sRegex, $sPath)
 {
     if (!$sRegex) {
         throw new ExceptionSitemap('An URI must be present.');
     }
     $sKey = $sRegex;
     if (array_key_exists($sKey, $this->aControllerMaps)) {
         unset($this->aControllerMaps[$sKey]);
     }
     if (class_exists($sPath)) {
         // instead of a path we have a namespace
         $oNewMap = new ClassMap($sPath, $sKey);
         $oNewMap->setModuleMap($this);
         $oNewMap->merge($this);
         $this->aControllerMaps[$sKey] = $oNewMap;
         return $oNewMap;
     } else {
         $sPath = str_replace(array('/', '\\'), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $sPath);
         if (!SiteMapA::isValidObjectPath($sPath)) {
             $sPath = $this->getModulePath() . $sPath;
         }
         if (SiteMapA::isValidObjectPath($sPath)) {
             $oNewMap = new ControllerMap($sPath, $sKey);
             $oNewMap->setModuleMap($this);
             $oNewMap->merge($this);
             $this->aControllerMaps[$sKey] = $oNewMap;
             return $oNewMap;
         } else {
             throw new ExceptionController('Controller [' . $sPath . '] is invalid.');
         }
     }
 }