/**
  * Boot the service provider.
  */
 public function boot(Dispatcher $events)
 {
     $events->fire(new Booting());
     // First load our app environment.
     $this->dispatch(new LoadEnvironmentOverrides());
     // Next take care of core utilities.
     $this->dispatch(new SetCoreConnection());
     $this->dispatch(new ConfigureCommandBus());
     $this->dispatch(new ConfigureUriValidator());
     $this->dispatch(new InitializeApplication());
     // Setup and preparing utilities.
     $this->dispatch(new LoadStreamsConfiguration());
     $this->dispatch(new AutoloadEntryModels());
     $this->dispatch(new AddAssetNamespaces());
     $this->dispatch(new AddImageNamespaces());
     $this->dispatch(new AddViewNamespaces());
     // Observe our base models.
     EntryModel::observe(EntryObserver::class);
     FieldModel::observe(FieldObserver::class);
     StreamModel::observe(StreamObserver::class);
     EloquentModel::observe(EloquentObserver::class);
     AssignmentModel::observe(AssignmentObserver::class);
     $this->app->booted(function () use($events) {
         $events->fire(new Booted());
         /* @var AddonManager $manager */
         $manager = $this->app->make('Anomaly\\Streams\\Platform\\Addon\\AddonManager');
         /* @var Dispatcher $events */
         $events = $this->app->make('Illuminate\\Contracts\\Events\\Dispatcher');
         $events->listen('Anomaly\\Streams\\Platform\\View\\Event\\RegisteringTwigPlugins', function (RegisteringTwigPlugins $event) {
             $twig = $event->getTwig();
             foreach ($this->plugins as $plugin) {
                 if (!$twig->hasExtension($plugin)) {
                     $twig->addExtension($this->app->make($plugin));
                 }
             }
             if (!$twig->hasExtension('markdown')) {
                 $twig->addExtension(new MarkdownExtension(new MichelfMarkdownEngine()));
             }
             $twig->addExtension(new Extension(new CacheStrategy(new CacheAdapter($this->app->make(Repository::class)), new CacheKey())));
         });
         $manager->register();
         $this->dispatch(new IncludeRoutes());
         $events->fire(new Ready());
     });
     $this->app->singleton('mailer', function () {
         $mailer = new Mailer($this->app['view'], $this->app['swift.mailer'], $this->app['events']);
         $mailer->setContainer($this->app);
         if ($this->app->bound('Psr\\Log\\LoggerInterface')) {
             $mailer->setLogger($this->app->make('Psr\\Log\\LoggerInterface'));
         }
         if ($this->app->bound('queue')) {
             $mailer->setQueue($this->app['queue.connection']);
         }
         $from = $this->app['config']['mail.from'];
         if (is_array($from) && isset($from['address'])) {
             $mailer->alwaysFrom($from['address'], $from['name']);
         }
         $to = $this->app['config']['mail.to'];
         if (is_array($to) && isset($to['address'])) {
             $mailer->alwaysTo($to['address'], $to['name']);
         }
         $pretend = $this->app['config']->get('mail.pretend', false);
         $mailer->pretend($pretend);
         return $mailer;
     });
     $this->app->singleton('Illuminate\\Mail\\Mailer', function () {
         return $this->app->make('mailer');
     });
     $this->app->singleton('Illuminate\\Contracts\\Mail\\Mailer', function () {
         return $this->app->make('mailer');
     });
     $this->dispatch(new ConfigureTranslator());
 }
 /**
  * Boot the service provider.
  */
 public function boot(Dispatcher $events)
 {
     $events->fire(new Booting());
     // First load our app environment.
     $this->dispatch(new LoadEnvironmentOverrides());
     // Next take care of core utilities.
     $this->dispatch(new SetCoreConnection());
     $this->dispatch(new ConfigureUriValidator());
     $this->dispatch(new InitializeApplication());
     // Setup and preparing utilities.
     $this->dispatch(new LoadStreamsConfiguration());
     $this->dispatch(new ConfigureTranslator());
     $this->dispatch(new AutoloadEntryModels());
     $this->dispatch(new AddAssetNamespaces());
     $this->dispatch(new AddImageNamespaces());
     $this->dispatch(new AddViewNamespaces());
     $this->dispatch(new ConfigureScout());
     // Observe our base models.
     EntryModel::observe(EntryObserver::class);
     FieldModel::observe(FieldObserver::class);
     StreamModel::observe(StreamObserver::class);
     EloquentModel::observe(EloquentObserver::class);
     AssignmentModel::observe(AssignmentObserver::class);
     $this->app->booted(function () use($events) {
         $events->fire(new Booted());
         /* @var AddonManager $manager */
         $manager = $this->app->make('Anomaly\\Streams\\Platform\\Addon\\AddonManager');
         /* @var Dispatcher $events */
         $events = $this->app->make('Illuminate\\Contracts\\Events\\Dispatcher');
         $events->listen('Anomaly\\Streams\\Platform\\View\\Event\\RegisteringTwigPlugins', function (RegisteringTwigPlugins $event) {
             $twig = $event->getTwig();
             foreach ($this->plugins as $plugin) {
                 if (!$twig->hasExtension($plugin)) {
                     $twig->addExtension($this->app->make($plugin));
                 }
             }
             if (!$twig->hasExtension('markdown')) {
                 $twig->addExtension(new MarkdownExtension(new MichelfMarkdownEngine()));
             }
             $twig->addExtension(new Extension(new CacheStrategy(new CacheAdapter($this->app->make(Repository::class)), new CacheKey())));
         });
         $manager->register();
         /*
          * Do this after addons are registered
          * so that they can override named routes.
          */
         $this->dispatch(new IncludeRoutes());
         $events->fire(new Ready());
     });
 }