Example #1
0
 /**
  * Constructor.
  *
  * create configuration object, database object
  * set up dispatcher and plugins (subscribers).
  * 
  * @param Config $config
  */
 private function __construct(Config $config)
 {
     try {
         $this->config = $config;
         $this->eventDispatcher = EventDispatcher::getInstance();
         $this->config->createConst();
         if (!ini_get('date.timezone')) {
             // @todo allow configuration in site.ini.xml
             date_default_timezone_set('Europe/Vienna');
         }
         // initialize available locales
         if (isset($this->config->site->locales)) {
             $this->locales = array_fill_keys($this->config->site->locales, NULL);
         }
         $this->useNiceUris = !!$this->config->site->use_nice_uris;
         // set a relative assets path when configured
         if (isset($this->config->site->assets_path)) {
             $this->setRelativeAssetsPath($this->config->site->assets_path);
         } else {
             $this->setRelativeAssetsPath('');
         }
     } catch (\Exception $e) {
         printf('<div style="border: solid 2px; color: #c00; font-weight: bold; padding: 1em; width: 40em; margin: auto; ">Application Error!<br>Message: %s</div>', $e->getMessage());
         exit;
     }
 }