public function register(Container $app)
 {
     $app['translator'] = function ($app) {
         if (!isset($app['locale'])) {
             throw new \LogicException('You must define \'locale\' parameter or register the LocaleServiceProvider to use the TranslationServiceProvider');
         }
         $translator = new Translator($app['locale'], $app['translator.message_selector'], $app['translator.cache_dir'], $app['debug']);
         $translator->setFallbackLocales($app['locale_fallbacks']);
         $translator->addLoader('array', new ArrayLoader());
         $translator->addLoader('xliff', new XliffFileLoader());
         // Register default resources
         foreach ($app['translator.resources'] as $resource) {
             $translator->addResource($resource[0], $resource[1], $resource[2], $resource[3]);
         }
         foreach ($app['translator.domains'] as $domain => $data) {
             foreach ($data as $locale => $messages) {
                 $translator->addResource('array', $messages, $locale, $domain);
             }
         }
         return $translator;
     };
     $app['translator.listener'] = function ($app) {
         return new TranslatorListener($app['translator'], $app['request_stack']);
     };
     $app['translator.message_selector'] = function () {
         return new MessageSelector();
     };
     $app['translator.resources'] = $app->protect(function ($app) {
         return [];
     });
     $app['translator.domains'] = [];
     $app['locale_fallbacks'] = ['en'];
     $app['translator.cache_dir'] = null;
 }
 /**
  * {@inheritdoc}
  */
 public function register(Container $app)
 {
     $app['console'] = function ($app) {
         $console = new Console($app);
         $app['events']->dispatch('console.init.event', new ConsoleEvent($console));
         return $console;
     };
     $app['console.register'] = $app->protect(function ($commands) {
         $this->commands($commands);
     });
     $app['composer'] = function ($app) {
         return new Composer($app['files']);
     };
     $this->commands($this->commands);
 }
 protected function factory(Container $app)
 {
     $app['session.factory'] = $app->protect(function ($options, $app) {
         $driver = $options['driver'];
         if ($driver != 'file' && is_callable($driver)) {
             return $options['driver']();
         }
         switch ($driver) {
             case 'null':
                 $storage = $app['session.driver.null']($options);
                 break;
             case 'memcache':
                 $storage = $app['session.driver.memcache']($options);
                 break;
             case 'memcached':
                 $storage = $app['session.driver.memcached']($options);
                 break;
             case 'file':
                 $storage = $app['session.driver.file']($options);
                 break;
             case 'mongodb':
                 $storage = $app['session.driver.mongodb']($options);
                 break;
         }
         return $storage;
     });
 }
 protected function factory(Container $app)
 {
     $app['cache.factory'] = $app->protect(function ($options, $app) {
         $driver = $options['driver'];
         if ($driver != 'file' && is_callable($driver)) {
             $cache = $options['driver']();
         } else {
             switch ($driver) {
                 case 'redis':
                     $cache = $app['cache.driver.redis']($options);
                     break;
                 case 'memcache':
                     $cache = $app['cache.driver.memcache']($options);
                     break;
                 case 'memcached':
                     $cache = $app['cache.driver.memcached']($options);
                     break;
                 case 'file':
                     $cache = $app['cache.driver.file']($options);
                     break;
                 case 'apc':
                     $cache = $app['cache.driver.apc']();
                     break;
                 case 'xcache':
                     $cache = $app['cache.driver.xcache']();
                     break;
                 case 'array':
                     $cache = $app['cache.driver.array']();
                     break;
                 case 'mongodb':
                     $cache = $app['cache.driver.mongodb']($options);
                     break;
             }
         }
         if (!$cache instanceof Cache) {
             throw new \UnexpectedValueException(sprintf('"%s" does not implement \\Doctrine\\Common\\Cache\\Cache', get_class($cache)));
         }
         if (isset($options['namespace']) && is_callable([$cache, 'setNamespace'])) {
             $cache->setNamespace($options['namespace']);
         }
         return new CacheNamespace($cache);
     });
 }