/** * Add a path to the class directories * * @param string $sDir The path to the directory * @param string|null $sNamespace The associated namespace * @param array $aExcluded The functions that are not to be exported * * @return boolean */ public function addClassDir($sDir, $sNamespace = null, array $aExcluded = array()) { if (!is_dir($sDir = trim($sDir))) { return false; } if (!($sNamespace = trim($sNamespace))) { $sNamespace = null; } if ($sNamespace) { $sNamespace = trim($sNamespace, '\\'); // If there is an autoloader, register the dir with PSR4 autoloading if ($this->xAutoloader) { $this->xAutoloader->setPsr4($sNamespace . '\\', $sDir); } } else { if ($this->xAutoloader) { // If there is an autoloader, register the dir with classmap autoloading $itDir = new RecursiveDirectoryIterator($sDir); $itFile = new RecursiveIteratorIterator($itDir); // Iterate on dir content foreach ($itFile as $xFile) { // skip everything except PHP files if (!$xFile->isFile() || $xFile->getExtension() != 'php') { continue; } $this->xAutoloader->addClassMap(array($xFile->getBasename('.php') => $xFile->getPathname())); } } } $this->aClassDirs[] = array('path' => $sDir, 'namespace' => $sNamespace, 'excluded' => $aExcluded); return true; }
/** * 자동 라우팅 처리 start * @throws ConfigureException * @throws DirectoryException */ protected function autoload() { System::config(); $siteConfig = Configure::site(); $siteNamespace = $siteConfig['namespace'] . "\\"; Autoloader::setPsr4(array($siteNamespace => array(Directory::sitePath('controller')), $siteNamespace . "Model\\" => array(Directory::sitePath('model')))); //방화벽 가동 Firewall::ruleStart(); //실제 작업 시작 $this->execute(); }