/**
  * @param Application|Container $app
  *
  */
 public function boot($app)
 {
     // only if enabled
     if ($app['config']['view.blade.enabled']) {
         // default blade context to simplify creating a new Blade|BladeView object.
         $app['blade.context'] = function ($app) {
             return new BladeConfigurationSet(['engine' => $app['blade.engine'], 'events' => $app['illuminate.events'], 'factory' => $app['blade.factory'], 'finder' => $app['view.finder'], 'global' => $app['global.scope'], 'paths' => $app['paths'], 'settings' => $app['blade.settings']]);
         };
         $this->container->add([BladeConfigurationSet::class, BladeViewConfigurationInterface::class], function () use($app) {
             return $app['blade.context'];
         });
         $this->container->add([BladeView::class, 'BladeView'], function () use($app) {
             return new BladeView($this->app['blade.context']);
         });
         // for dependency injection. ie: DI::make(BladeView::class)
         $app[BladeViewConfigurationInterface::class] = function ($app) {
             return $app['blade.context'];
         };
         $app['blade'] = $app->factory(function () {
             return new Blade($this->app['blade.context']);
         });
         $app['blade.view'] = $app->factory(function () {
             return new BladeView($this->app['blade.context']);
         });
     }
 }
 /**
  * @param Application|Container $app
  *
  */
 public function boot($app)
 {
     /** @var Forge $container */
     list($config, $container) = [$this->config, $this->container];
     // only boot if twig templates are enabled by the framework
     if ($this->config['view.twig.enabled']) {
         $app['twig.context'] = function ($app) {
             return new TwigConfigurationSet(['events' => $app['nine.events'], 'finder' => $app['twig.finder'], 'global' => $app['global.scope'], 'paths' => $app['paths'], 'settings' => $app['twig.settings']]);
         };
         $app['twig.view'] = $app->factory(function ($app) {
             return new TwigView($app['twig.context']);
         });
         $container->singleton([TwigConfigurationSet::class, TwigViewConfigurationInterface::class], function () use($app) {
             return $app['twig.context'];
         });
         $container->add([TwigView::class, 'TwigView'], function () use($app) {
             return new TwigView($app['twig.context']);
         });
     }
 }
Esempio n. 3
0
 /**
  * Attempt locating an abstract (passing any supplied parameters)
  * from the container and the embedded Application.
  *
  * *Order of events:*
  *      1. Does the abstract exist in the app container?
  *      2. Does the abstract exist in the container?
  *      3. Fail with ContainerAbstractNotFound exception.
  *
  * @param string     $abstract
  * @param array|NULL $parameters
  *
  * @return mixed|null
  *
  * @throws DependencyInstanceNotFound
  */
 public static function find($abstract, array $parameters = [])
 {
     static::$instance = static::$instance ?: new static();
     // find in the app first
     if (static::$app and static::$app->offsetExists($abstract)) {
         return static::$app[$abstract];
     }
     // find in Illuminate/Container
     if (static::$instance->bound($abstract)) {
         return static::$instance->make($abstract, $parameters);
     }
     throw new DependencyInstanceNotFound("Dependency or instance `{$abstract}` not found.");
 }