/** * Constrict the dispatcher * * @param string $inUsePHPExtension * @param string $inContextRootUrl * @param string $inContextRootPath * @param array $externalResourcePaths * @param string $inModuleClass * @param string $inDefaultPageClass * * @return void */ public function __construct($inUsePHPExtension = null, $inContextRootUrl = null, $inContextRootPath = null, $externalResourcePaths = array(), $inModuleClass = null, $inDefaultPageClass = null) { self::$sInstance = $this; // try to guess if ($inUsePHPExtension === null) { // if the SCRIPT_NAME is a subset of the REQUEST_URI, then we are using the extension, otherwise // we must be using mod_rewrite if (strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']) === 0) { $inUsePHPExtension = true; } else { $inUsePHPExtension = false; } } if ($inContextRootUrl == null) { $inContextRootUrl = $this->determineContextRootUrl(); } if ($inContextRootPath == null) { $inContextRootPath = $this->determineContextRootPath(); } $contextUri = $this->determineContextUri(); $dispatchPathInfo = pathinfo($_SERVER['SCRIPT_FILENAME']); $dispatchUri = $inUsePHPExtension ? "{$dispatchPathInfo['filename']}.{$dispatchPathInfo['extension']}" : $dispatchPathInfo['filename']; $this->defaultPageClass = $inDefaultPageClass; $this->req = new RequestContext($inContextRootUrl, $inContextRootPath, $contextUri, $dispatchUri, $externalResourcePaths); $this->resp = new ResponseContext(); /* @var $app Application */ $app = Application::createApplication(); if ($inModuleClass == null) { $inModuleClass = $app->getDefaultModuleClass(); } $this->moduleClass = $inModuleClass; $app->initializeModules($inContextRootUrl, $inModuleClass, $inUsePHPExtension); }