Exemplo n.º 1
0
 /**
  *	initialize required objects 
  */
 public function init()
 {
     $this->config = Registry::getInstance()->config = ApplicationConfig::getInstance();
     $request = Registry::getInstance()->request = new Request();
     $this->setAppName($this->config->appName);
     $this->setRouter(Router::getInstance())->setRequest($request)->setRawRoute()->setDefaultModule('site')->setDefaultController('site')->setDefaultAction('index')->setBasePath(dirname(dirname(dirname(__FILE__))))->setModule()->setController()->setAction();
     // load module (modules which are in extension folders ) configuration
     ModuleManager::getInstance()->loadModuleConfig();
     //set application configurations config.ini
     // Load system configuration system.xml
     $this->config->setConfigFile($this->getConfigFile())->setSystemConfigFile($this->getSystemConfigFile())->loadConfiguration();
     // load the userspace bootstrap class and run init method
     $initialize = Registry::getInstance()->request->getBasePath() . DS . Registry::getInstance()->config->appDir . DS . 'initializer.php';
     if (file_exists($initialize)) {
         $initializer = new \initializer();
         $initializer->init();
     }
     // Module specific configuration file <module>.xml
     ModuleConfig::getInstance()->loadConfiguration();
     // load plugin configurations
     PluginManager::getInstance()->loadPluginConfig();
     // load plugins
     PluginManager::getInstance()->loadPlugins();
     $this->exception = new EasyException(null);
     return $this;
 }
Exemplo n.º 2
0
 public function getModuleConfigPath()
 {
     $path = null;
     if (ModuleManager::getInstance()->shouldOverridden($this->getRequest()->getModule()) == true) {
         // if there is no listner attached to the module load event, default behaiour is override the module
         // and load
         if (EventDispatcher::getInstance()->hasListener('before.module.load') == false) {
             return $this->constructPath();
         }
         // Listner is attached to this event, let's trigger the event and check if listener retrun true
         // Override the module
         if (EventDispatcher::getInstance()->trigger('before.module.load', $this->getRequest()->getModule()) == true) {
             return $this->constructPath();
         }
     }
     // if current module is not configured to overridden, simply load module configuration file
     // from app/modules directory
     $module = $this->getRequest()->getModule();
     return $this->getRequest()->getBasePath() . DS . Registry::getInstance('config')->appDir . DS . 'modules' . DS . $module . DS . strtolower($module) . '.xml';
 }
Exemplo n.º 3
0
 /**
  *	Set Route according to request
  */
 public function setRoute()
 {
     //Check if the requested module is configured to overriden,  Set the Route to load that overrider module
     $this->matchRoute($this->getRequest()->getRawRoute());
     //check to see if current module is configured to overridden
     if (ModuleManager::getInstance()->shouldOverridden($this->getRequest()->getModule()) == true) {
         // if there is no listner attached to the before.module.load event, default behaiour is override the module
         if (EventDispatcher::getInstance()->hasListener('before.module.load') == false) {
             $this->overrideModule();
             return $this;
         }
         // Listner is attached to this event, let's trigger the event and check if listener retruns true,
         // Override the module
         if (EventDispatcher::getInstance()->trigger('before.module.load', $this->getRequest()->getModule()) == true) {
             $this->overrideModule();
             return $this;
         }
     }
     // Check to see which site this request is for
     // if current module is not configured to overridden, simply load module from app/modules directory
     $namespace = $this->getRequest()->getModule() . '\\Controller';
     $this->class = $this->getRequest()->getCurrentController() . 'Controller';
     $this->route = $namespace . '\\' . $this->class;
     return $this;
 }