/** * @return void */ public function Handle() { $mResult = ''; $bError = false; $bIsHtml = false; $this->GetVersion(); $this->CheckApi(); $this->RedirectToHttps(); $aPaths = self::GetPaths(); $aModules = array(); if (0 < count($aPaths) && !empty($aPaths[0])) { $sEntry = strtolower($aPaths[0]); $oModule = $this->oModuleManager->GetModuleFromRequest(); if ($oModule instanceof \AApiModule) { if ($oModule->HasEntry($sEntry)) { $aModules[] = $oModule; } else { $mResult = '\'' . $sEntry . '\' entry not found in \'' . $oModule->GetName() . '\' module.'; $bError = true; } } else { if ($sEntry === 'api') { $oCoreModule = \CApi::GetModule('Core'); if ($oCoreModule instanceof \AApiModule) { $aModules[] = $oCoreModule; } } else { $aModules = $this->oModuleManager->GetModulesByEntry($sEntry); } } if (!$bError) { if (count($aModules) > 0) { foreach ($aModules as $oModule) { $mEntryResult = $oModule->RunEntry($sEntry); if ($mEntryResult !== 'null') { $mResult .= $mEntryResult; } } } else { $bIsHtml = true; } } } else { $bIsHtml = true; } if ($bIsHtml) { $mResult = $this->generateHTML(); } $oHttp = \MailSo\Base\Http::SingletonInstance(); if ($oHttp->GetRequest('Format') !== 'Raw') { echo $mResult; } }
public static function GetModuleManager() { if (!isset(CApi::$oModuleManager)) { CApi::$oModuleManager = CApiModuleManager::createInstance(); CApi::$oModuleManager->init(); } return CApi::$oModuleManager; }