<?php

namespace Components;

if (Environment::isDev()) {
    I18n_Scriptlet_Import_Cldr_Common::serve('import/cldr/common');
    I18n_Scriptlet_Import_Cldr_Script::serve('import/cldr/script');
}
<?php

namespace Components;

Log::push(new Log_Appender_Syslog(COMPONENTS_APP_CODE));
if (Environment::isDev()) {
    Runtime::addManagementIp(Runtime::getClientAddress());
}
if (isset($_REQUEST['debug']) || Environment::isDev()) {
    if (isset($_REQUEST['debug'])) {
        $debug = (int) $_REQUEST['debug'];
    } else {
        $debug = Debug::INFO;
    }
    if (0 < $debug) {
        Debug::activate();
    }
    Debug::verbosity($debug);
    Debug::appender(Debug::INFO, new Debug_Appender_Console());
    Debug::enable(Debug::MARKUP);
}
 /**
  * @link http://php.net/manual/en/function.register-shutdown-function.php
  */
 public function onExit()
 {
     $error = error_get_last();
     if (null !== $error) {
         $this->onError($error['type'], $error['message'], $error['file'], $error['line']);
     }
     if (self::$m_isCli) {
         $hasErrors = 0 < count(self::$m_exceptions);
         foreach (self::$m_exceptions as $exception) {
             exception_print_cli($exception, true, true);
         }
         if (false === @is_file(self::$m_cacheFile)) {
             Cache::dump(self::$m_cacheFile);
         }
         exit(false === $hasErrors ? 0 : -1);
     }
     if (Debug::active() && (self::isManagementAccess() || Environment::isDev())) {
         if (0 < count(self::$m_exceptions)) {
             Debug::verror(self::$m_exceptions);
         }
         Debug::flush();
         self::$m_exceptions = [];
     }
     if (false === Environment::isDev()) {
         self::$m_exceptions = [];
     }
     foreach (self::$m_exceptions as $exception) {
         exception_print_html($exception, true, true);
     }
 }