Beispiel #1
0
 /**
  * It returns the value of the specified variable
  * This is not a value contained in a config file but a value previously 
  * assigned in runtime by Pokelio_Global::setVar
  * 
  * @param string $param   Name of the variable
  * @param string $module  Name of the variable's module
  * @return mixed     
  */
 public static function getVar($var, $module = 'Pokelio')
 {
     if (!isset($GLOBALS['vars' . $module][$var])) {
         Pokelio_Error::triggerError("Global var {$var} not defined in module {$module}.");
     }
     return $GLOBALS['vars' . $module][$var];
 }
 /**
  * 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();
     }
 }