/** * registers module according to uri given * * @return bool true if module successfully loaded; <br /> * false otherwise; */ public function handle() { $boolReturn = false; $oLogger = $this->di->getFileLogger(); $oPreRouter = new Router(); $oPreRouter->add('/api(.*)', array('module' => 'api')); $oPreRouter->add('/regular(.*)', array('module' => 'regular')); $oPreRouter->add('/blind(.*)', array('module' => 'blind')); $oPreRouter->handle(); $strModuleName = $oPreRouter->getModuleName(); /** * @type Request $oRequest */ $oRequest = $this->di->getRequest(); if (array_key_exists($strModuleName, $this->knownModules)) { $this->app->registerModules(array($strModuleName => $this->knownModules[$strModuleName])); $this->app->setDefaultModule($strModuleName); $boolReturn = true; $oLogger->debug(__CLASS__ . ': ' . $oRequest->getURI() . ' leads to module: ' . $strModuleName); } else { if (!U::isLegacy()) { $strMsg = 'failed to load phalcon module'; } else { $strMsg = 'loading old backend'; } $oLogger->debug(__CLASS__ . ': ' . $strMsg . ' for "' . $oRequest->getUri() . '"'); } return $boolReturn; }
private function pathFinder($strMedia, $intMajorVersion, $intMinorVersion) { $strReturn = ''; $oLogger = $this->_di->getFileLogger(); // $oChecker = new Checker(); $strBaseDir = __DIR__ . DIRECTORY_SEPARATOR . $strMedia . DIRECTORY_SEPARATOR . 'v' . $intMajorVersion . '_'; $intMinorVersion = (int) $intMinorVersion; for ($i = $intMinorVersion; $i >= 0; $i--) { $strDir = $strBaseDir . $intMinorVersion . DIRECTORY_SEPARATOR . 'controllers'; $oChecker = new Checker($strDir, $this->dispatcher->getControllerClass()); if ($oChecker->methodExists($this->dispatcher->getActiveMethod())) { $oLogger->debug(__CLASS__ . '->' . __FUNCTION__ . ':: ' . $this->dispatcher->getControllerClass() . '->' . $this->dispatcher->getActiveMethod() . ' lays in ' . $strDir); $strReturn = $strDir; break; } else { $oLogger->debug(__CLASS__ . '->' . __FUNCTION__ . ':: ' . $this->dispatcher->getControllerClass() . '->' . $this->dispatcher->getActiveMethod() . ' not found in ' . $strDir); } // if($strTokens = $oChecker->classExists($strDir, $this->dispatcher->getControllerClass())){ // // $oLogger->debug('tokens: ' . $strTokens); // } } return $strReturn; }