Пример #1
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.');
         }
     }
 }