예제 #1
0
파일: Config.php 프로젝트: ktrzos/plethora
 /**
  * Load config file
  *
  * Get array from config file and save it to variable
  *
  * @static
  * @access   public
  * @param    string $sConfigPath
  * @param    string $sFormat
  * @return   bool
  * @throws   Exception
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 private static function load($sConfigPath, $sFormat = 'php')
 {
     $oConfigData = static::findConfigFile($sConfigPath, $sFormat);
     // load config data
     if ($oConfigData !== FALSE) {
         switch ($sFormat) {
             # PHP
             case 'php':
                 $aConfig = (include $oConfigData->getPath());
                 break;
                 # YAML
             # YAML
             case "yml":
                 $aConfig = \Spyc::YAMLLoad($oConfigData->getPath());
                 break;
         }
     }
     // assign data to storage
     if (isset($aConfig)) {
         Helper\Arrays::createMultiKeys(static::$aConfigs, $sConfigPath, $aConfig);
         unset($aConfig);
         Log::insert('Config ' . $sConfigPath . ' (' . $sFormat . ') loaded');
         return TRUE;
     }
     // if there is no data to assign (because the config file does not exists), create ERROR message and return FALSE (or throw exception)
     $sMsg = 'Unable to load ' . $sConfigPath . ' config file with "' . $sFormat . '" format.';
     Log::insert($sMsg, Log::ERROR);
     if (Core::getAppMode() === Core::MODE_DEVELOPMENT) {
         throw new Exception($sMsg);
     }
     return FALSE;
 }
예제 #2
0
파일: Fatal.php 프로젝트: ktrzos/plethora
 /**
  * Fatal error handler.
  *
  * @access     public
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public function handler()
 {
     if (Core::getAppMode() == Core::MODE_DEVELOPMENT) {
         throw $this;
     } else {
         header('HTTP/1.0 ' . $this->sHeaderContent);
         echo View::factory('base/error_pages/500')->render();
         die;
     }
 }
예제 #3
0
define('PATH_CACHE', PATH_APP . 'cache' . DS);
// Cache path
define('PATH_G_VIEWS', PATH_APP . 'views' . DS);
// Global views path
// styles and images path
define('PATH_CSS', '/css/');
define('PATH_IMAGES', '/images/');
// show all errors if development mode is on
//if(\Plethora\Core::getAppMode() == \Plethora\Core::MODE_DEVELOPMENT) {
error_reporting(E_ALL);
ini_set('display_errors', '1');
//require_once PATH_LIB.'KintDebug/Kint.class.php';
//}
// Load global functions
require PATH_CORE . 'functions.php';
// show content
if (file_exists('./install.php')) {
    require_once PATH_PUBLIC . 'install.php';
} else {
    if (\Plethora\Core::getAppMode() == \Plethora\Core::MODE_DEVELOPMENT) {
        \Plethora\Core::startApp();
    } else {
        try {
            \Plethora\Core::startApp();
        } catch (\Plethora\Exception $e) {
            $e->handler();
        }
    }
}
// destruct Log instance
\Plethora\Log::destruct();
예제 #4
0
/**
 * Errors handler.
 *
 * @author   Krzysztof Trzos
 * @param    integer $errno
 * @param    string  $errstr
 * @param    string  $errfile
 * @param    integer $errline
 * @param    array   $errcontext
 * @throws   Exception\Fatal
 * @since    1.0.0-alpha
 * @version  1.0.0-alpha
 */
function error_handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = [])
{
    $iLevel = ob_get_level();
    for ($i = 1; $i < $iLevel; $i++) {
        ob_get_clean();
    }
    if (Core::getAppMode() == Core::MODE_DEVELOPMENT) {
        \Kint::trace();
        ddd($errno, $errstr, $errfile, $errline, $errcontext);
    } else {
        try {
            throw new Exception\Fatal();
        } catch (Exception $e) {
            $e->handler();
        }
    }
}