예제 #1
0
 /**
  * @param string $sRegex
  * @param string $sPath
  * @throws ExceptionSitemap
  * @returns MappingA
  */
 protected function addClassMap($sRegex, $sPath)
 {
     $oModuleMap = $this->getCurrentModuleMap();
     $oNewMap = null;
     if (MappingA::isValid($oModuleMap)) {
         $sRegex = $oModuleMap->getRegex() . $sRegex;
     }
     if (!array_key_exists($sRegex, $this->aMaps)) {
         $oNewMap = new ClassMap($sPath, $sRegex);
         if (MappingA::isValid($oModuleMap)) {
             $oNewMap->merge($oModuleMap);
             $oNewMap->setModuleMap($oModuleMap);
         }
         $this->aMaps[$sRegex] = $oNewMap;
     }
     return $oNewMap;
 }
예제 #2
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.');
         }
     }
 }