Ejemplo n.º 1
0
 private function getCurrentLocale()
 {
     if ($this->container->isDefined(RouteAttribute::LOCALE)) {
         return $this->container->get(RouteAttribute::LOCALE);
     } else {
         return $this->config->get('translation.defaultLocale', null);
     }
 }
Ejemplo n.º 2
0
 private function assertLocaleConfig()
 {
     $this->defaultLocale = $this->config->get('translation.defaultLocale', null);
     $this->availableLocales = $this->config->get('translation.availableLocales', []);
     if (empty($this->availableLocales)) {
         throw new InvalidConfigException("Invalid or missing translation.availableLocales configuration!");
     }
     if (empty($this->defaultLocale)) {
         throw new InvalidConfigException("Invalid or missing translation.defaultLocale configuration!");
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates a Logger component
  */
 private function createLogger()
 {
     $logFolder = $this->filesystem->assertFolderWritable($this->rootFolder . '/var/log');
     $logLevel = $this->debug === true ? LogLevel::DEBUG : $this->config->get('logger.level', LogLevel::WARNING);
     $args = [$logFolder, $this->config->get('logger.name', 'application'), $this->config->get('logger.filelogger.maxfiles', 10), $logLevel];
     $this->logger = (new \ReflectionClass($this->loggerFactory))->newInstanceArgs($args)->create();
     $this->logger->debug('Logger started');
 }
Ejemplo n.º 4
0
 protected function initialize(Configuration $config)
 {
     date_default_timezone_set($config->get('timezone', 'UTC'));
     $this->container = new ServiceContainer();
     $this->dispatcher = new EventDispatcher();
     $this->filesystem = new Filesystem();
     $this->container->setScalars([LoggerInterface::class => $this->logger, Configuration::class => $config, LocalCache::class => $this->localCache, EventDispatcherInterface::class => $this->dispatcher, Container::class => $this->container, Filesystem::class => $this->filesystem, RuntimeAttribute::APPLICATION_ROOT_FOLDER => $this->rootFolder, RuntimeAttribute::APPLICATION_CACHE_FOLDER => $this->localCache->getCacheFolder(), RuntimeAttribute::DEBUG => $config->get('debug', false)]);
     /**
      * Adds the SecurityHandler class by default. This will
      * add a small overdead to the request/response cycle
      * but we gain functionality by having a _authenticated_user
      * when possible
      */
     $this->container->defineSingleton(SecurityHandler::class);
     if (!$this->container->loadServicesFromFile($this->rootFolder . '/config/services.json')) {
         $this->logger->notice("No service description file found!");
     }
     $this->installEventSubscribers();
 }
Ejemplo n.º 5
0
 public function create()
 {
     $appname = strtolower($this->config->get('name'));
     return new Database(['host' => $this->config->get('database.host', '127.0.0.1'), 'port' => $this->config->get('database.port', 5432), 'database' => $this->config->get('database.database', $appname), 'username' => $this->config->get('database.username', $appname), 'password' => $this->config->get('database.password')], $this->logger);
 }