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;
 }
Exemple #2
0
 public function boot(Container $app)
 {
     if (!$app->isWeb()) {
         return true;
     }
     $this->loadForWeb($app);
     $this->noty();
 }
 public function boot(Container $app)
 {
     if (!$app->isWeb()) {
         return true;
     }
     $router = $app['resolver']->helper('router');
     Router::addRewrite($router);
     $values = Router::route();
     $app['request']->addInput($values);
     $this->registerNonApi($app);
 }
 /**
  * {@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);
 }
Exemple #5
0
 public function __construct($basePath = null)
 {
     parent::__construct();
     static::setInstance($this);
     if ($basePath) {
         $this->setBasePath($basePath);
     }
 }
Exemple #6
0
 /**
  * {@inheritdoc}
  */
 public function bootstrap()
 {
     if (!$this->app->isBootStrapped()) {
         $this->app->bootstrap($this->bootStrappers());
     }
     if (!$this->app->isBooted()) {
         $this->app->boot();
     }
 }
 /**
  * {@inheritdoc}
  */
 public function register(Container $app)
 {
     $app['fs'] = function ($app) {
         return new Filesystem();
     };
     $app['files'] = function ($app) {
         return $app['fs'];
     };
     $app['finder'] = $app->factory(function () {
         return Finder::create();
     });
     $app['filesystem'] = function ($app) {
         return new FilesystemManager($app);
     };
     $app['filesystem.disk'] = function ($app) {
         $config = $app['filesystems.default'] ? $app['filesystems.default'] : $app['config']->get('filesystems.default');
         return $app['filesystem']->disk($config);
     };
     $app['filesystem.cloud'] = function ($app) {
         $config = $app['filesystems.cloud'] ? $app['filesystems.cloud'] : $app['config']->get('filesystems.cloud');
         return $app['filesystem']->disk($config);
     };
 }
 public function boot(Container $app)
 {
     if (!$app->isWeb()) {
         return true;
     }
     $this->setUpTheme($app);
     $this->assignVars($app);
 }
 protected function setUpConstants(Container $app)
 {
     define('_SITENAME', $app['config']->get('app.name'));
     define('_ADMIN_MAIL', $app['config']->get('app.email'));
     /*========================================================
                       SOME GLOBAL DEFINATIONS
       /*********************************************************/
     $name = strtolower(rtrim($app->getNameSpace(), '\\'));
     define('SYSTEM', APP . $name . DS);
     defined('PUBLICD') or define('PUBLICD', APP . 'public' . DS);
     defined('UPLOAD') or define('UPLOAD', PUBLICD . 'uploads' . DS);
     defined('IMAGES') or define('IMAGES', UPLOAD);
     defined('MEDIA') or define('MEDIA', UPLOAD . 'media' . DS);
     defined('STATICD') or define('STATICD', PUBLICD . 'static/');
     defined('STORAGE') or define('STORAGE', APP . 'storage' . DS);
     defined('TMP') or define('TMP', STORAGE . 'tmp' . DS);
     defined('CACHE') or define('CACHE', STORAGE . 'cache' . DS);
     defined('LOGS') or define('LOGS', STORAGE . 'logs' . DS);
     defined('THEMES') or define('THEMES', PUBLICD . 'themes' . DS);
     /*========================================================
                       COOKIE SETTINGS
       /*********************************************************/
     define('COOKIE_SUFX', md5($app['config']->get('session.options.cookie_domain')));
     define('COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', _URL));
     define('COOKIE_NAME', 'NAME_' . COOKIE_SUFX);
     define('COOKIE_KEY', 'KEY_' . COOKIE_SUFX);
     define('COOKIE_UID', 'UID_' . COOKIE_SUFX);
     define('COOKIE_TIME', 864000);
     //    10 days : 60(sec)*60(min)*24(hrs)*10(days)
 }
 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);
     });
 }