Exemple #1
0
 /**
  * Error manager (non fatal errors)
  * It manages errors and decides what to do based on rules defined in the config file
  * 
  * @param integer $errno      Severity of error
  * @param string  $errstr     Description of error
  * @param string  $errfile    File where the error happened
  * @param integer $errline    Line of file where the error happened
  * @param array   $errcontext Context of error. Additional info.
  * 
  * This function is not invoked by the app. Instead of that, PHP interpreter invokes it
  * each time an error occurs
  */
 public static function PokelioErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
 {
     //Get the error handling rules from configuration array
     $errorRules = Pokelio_Global::getConfig('ERROR_HANDLING_RULES', 'Pokelio');
     //Should we Inform to user?
     if ($errorRules->{$errno}->I && $errorRules->all->I) {
         $text = self::getErrorPage($errno, $errstr, $errfile, $errline, $errcontext);
         if (SESSION_TYPE == 'WEB') {
             ob_clean();
             echo "<pre>" . htmlentities($text) . "</pre>";
         } else {
             echo $text;
         }
     }
     //Should we write to log file?
     if ($errorRules->{$errno}->L && $errorRules->all->L) {
         Pokelio_Log::write($errno . " " . $errstr . " " . $errfile . " " . $errline, $errno);
     }
     //Should we Stop execution?
     if ($errorRules->{$errno}->S && $errorRules->all->S) {
         Pokelio_Application::abort();
     }
     //Send error to App just in case we need to process it there
     $errorData = array();
     $errorData['errno'] = $errno;
     $errorData['errstr'] = $errstr;
     $errorData['errfile'] = $errfile;
     $errorData['errline'] = $errline;
     $errorData['errcontext'] = $errcontext;
     Pokelio_Callback::invokeCallback('Pokelio', 'Error', 'ErrorCaptured', $errorData);
 }
 /**
  * Defines the set of constants for the consumer app file locations
  */
 private function setAppPaths($appRealPath)
 {
     //Apps's root folder
     define('APP_ROOT_PATH', $appRealPath);
     //Classes
     define('APP_CLASSES_PATH', APP_ROOT_PATH . '/Classes');
     //Modules
     define('APP_MODULES_PATH', APP_ROOT_PATH . '/Modules');
     //Templates (header, footer, ... not the module ones)
     define('APP_TEMPLATE_PATH', APP_ROOT_PATH . '/Template');
     //CallBack
     Pokelio_Callback::invokeCallback('Pokelio', 'Application', 'endAppPaths');
 }
 /**
  * 
  * 
  * @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');
     }
 }