Esempio n. 1
0
 /**
  * Set up the environment according to configuration file specifications
  * 
  * @param string  $configPath   The path of the folder containing Pokelio.json configuration file
  * @param string  $appRealPath  Where the consumer app is
  */
 public function __construct($configPath, $appRealPath)
 {
     //Set Pokelio Version
     $this->version = "1.1.0";
     //Config
     define('APP_CONFIG_PATH', $configPath);
     //Check if config file exists
     $configFile = APP_CONFIG_PATH . '/Pokelio.json';
     if (!file_exists($configFile)) {
         //Can´t use Pokelio_Error class to raise error here
         die("Pokelio config file [{$configFile}] not found. Can´t continue.");
     }
     //Set Pokelio path constants
     $this->setPokelioPaths();
     //Set loader function for Pokelio classes
     require POKELIO_CLASSES_PATH . '/Loader/Loader.php';
     Pokelio_Loader::setLoader();
     //Load special classes
     require POKELIO_CLASSES_PATH . '/ShortCuts.php';
     //Register Pokelio Modules
     Pokelio_Module::registerModules(POKELIO_MODULES_PATH);
     //Set consumer application path constants
     $this->setAppPaths($appRealPath);
     //Register App Modules
     Pokelio_Module::registerModules(APP_MODULES_PATH, true);
     //Load configuration file
     Pokelio_Global::loadConfigFile($configFile, 'Pokelio');
     //Set error manager
     Pokelio_Error::setErrorHandler();
     //Set fatal error manager
     Pokelio_Error::setFatalErrorHandler();
     //Disable error reporting as we are managing that
     $phpErrorReport = Pokelio_Global::getConfig('PHP_ERROR_REPORTING', 'Pokelio');
     ini_set('error_reporting', $phpErrorReport);
     //Set exception manager
     Pokelio_Exception::setExceptionHandler();
     //Set timezone
     date_default_timezone_set(Pokelio_Global::getConfig('TIMEZONE'));
     //CallBack
     Pokelio_Callback::invokeCallback('Pokelio', 'Application', 'endConfiguration');
     //Determine if CLI or WEB Session
     if (php_sapi_name() == 'cli') {
         $this->cliManager();
     } else {
         $this->webManager();
     }
 }
Esempio n. 2
0
 /**
  * 
  * 
  * @param string   $modulesPath  Path to folder containing the module
  * @param string   $module         
  * @param boolean  $callback       
  * 
  */
 private static function registerModule($modulePath, $module, $callback = false)
 {
     //Load configuration of the module and callBack to notify
     $configFile = APP_CONFIG_PATH . '/' . $module . '.json';
     Pokelio_Global::loadConfigFile($configFile, $module);
     //Does the module contain a class loader?
     $loaderClassFile = $modulePath . '/' . $module . '/Classes/Loader/Loader.php';
     if (file_exists($loaderClassFile)) {
         require $loaderClassFile;
         if (is_callable($module . '_Loader::setLoader')) {
             call_user_func($module . '_Loader::setLoader');
         }
     }
     //CallBack
     if ($callback == true) {
         Pokelio_Callback::invokeCallback($module, 'Module', 'moduleRegistered');
     }
 }