private function __construct()
 {
     $configFile = __DIR__ . '/../../config/settings.yml';
     $localConfigFile = __DIR__ . '/../../config/settings.local.yml';
     if (!file_exists($configFile)) {
         throw new \Exception("No config file found in dummy Application");
     }
     $configFactory = new ConfigurationFactory($configFile, $localConfigFile);
     $this->_config = $configFactory->getConfig();
     $logFileName = __DIR__ . '/../../../logs/' . self::N5_TESTS_NAME . '-debug.log';
     $GLOBALS['logger'] = LoggerFactory::instance()->getLogger();
     //$GLOBALS['logger']->addHandler($logFileName, Logger::ALL, self::$LOG_MAPPING[$this->_config->getLogLevel()]);
 }
Example #2
0
 /**
  * init 
  * 
  * @param string $configFile Configuration with which to initialize an app with
  *
  * @static
  * @access public
  * @return void
  */
 public static function init($configFile = 'config/settings.yml', $localConfigFile = 'config/settings.local.yml')
 {
     // Check what php SAPI is being used
     self::$_cli = false;
     if (strcmp(php_sapi_name(), 'cli') === 0) {
         self::$_cli = true;
     }
     // Initialize application services, Store application Object as a global
     // Services are available from global app.
     $GLOBALS['app'] = $app = new self();
     $GLOBALS['logger'] = LoggerFactory::instance()->getLogger();
     $GLOBALS['routeLogger'] = LoggerFactory::instance()->getLogger();
     $configFactory = new ConfigurationFactory($configFile, $localConfigFile);
     $app->_config = $configFactory->getConfig();
     $logFolder = getcwd() . '/logs';
     if (!file_exists($logFolder)) {
         if (!mkdir($logFolder)) {
             $logFolder = sys_get_temp_dir() . '/logs';
             if (!file_exists($logFolder) && !mkdir($logFolder)) {
                 die('Insufficient privileges to create logs folder in application directory, or temp path, exiting');
             }
         }
     }
     $file = $logFolder . DIRECTORY_SEPARATOR . $app->_config->getApplicationContext() . '-debug.log';
     $GLOBALS['logger']->addHandler($file, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()]);
     $analyticsFile = $logFolder . DIRECTORY_SEPARATOR . $app->_config->getApplicationContext() . '-analytics.log';
     $GLOBALS['routeLogger']->addHandler($analyticsFile, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()], 'analytics');
     if (!self::$_cli) {
         $sessionManager = new WebSessionManager();
         $sessionManager->startSession(null, true);
         $app->_services['sessions'] = $sessionManager;
         SecurityUtils::setSecurityManager(new DefaultSecurityManager());
         $app->_subject = $app->_getSubjectFromSession($sessionManager->getActiveSession());
         $app->_services['routing'] = new RoutingEngine();
     }
     $app->_services['messaging'] = NotificationService::instance();
     return $app;
 }