Ejemplo n.º 1
0
 public function __construct()
 {
     $this->instance('container', $this);
     $this->singleton('events', function () {
         return new Dispatcher();
     });
     $this->singleton('files', function () {
         return new Filesystem();
     });
     $this->singleton('blade.compiler', function () {
         return new BladeCompiler($this['files'], $this['view.compiled']);
     });
     $this->singleton('view.engine.resolver', function () {
         $resolver = new EngineResolver();
         $resolver->register('blade', function () {
             return new CompilerEngine($this['blade.compiler'], $this['files']);
         });
         $resolver->register('php', function () {
             return new PhpEngine();
         });
         return $resolver;
     });
     $this->singleton('view.finder', function () {
         return new FileViewFinder($this['files'], $this['view.paths']);
     });
     $this->singleton('view', function () {
         $env = new Factory($this['view.engine.resolver'], $this['view.finder'], $this['events']);
         $env->setContainer($this['container']);
         return $env;
     });
 }
Ejemplo n.º 2
0
 public function register(Container $pimple)
 {
     $pimple['files'] = function () {
         return new Filesystem();
     };
     $pimple['view.engine.resolver'] = function () use($pimple) {
         $resolver = new EngineResolver();
         foreach (['php', 'blade'] as $engine) {
             $this->{'register' . ucfirst($engine) . 'Engine'}($resolver, $pimple);
         }
         return $resolver;
     };
     $pimple['view.finder'] = function () use($pimple) {
         $paths = $pimple['config']['view.paths'];
         return new FileViewFinder($pimple['files'], $paths);
     };
     $pimple['view'] = function () use($pimple) {
         // Next we need to grab the engine resolver instance that will be used by the
         // environment. The resolver will be used by an environment to get each of
         // the various engine implementations such as plain PHP or Blade engine.
         $resolver = $pimple['view.engine.resolver'];
         $finder = $pimple['view.finder'];
         $env = new Factory($resolver, $finder, $pimple['events']);
         // We will also set the container instance on this view environment since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $env->setContainer($pimple['container']);
         $env->share('app', $pimple);
         return $env;
     };
 }
 protected function makeView()
 {
     $app = new Container();
     $resolver = new EngineResolver();
     $resolver->register('php', function () {
         return new PhpEngine();
     });
     $finder = new FileViewFinder(new Filesystem(), [realpath(__DIR__)]);
     $dispatcher = (new Dispatcher($app))->setQueueResolver(function () use($app) {
         return $app->make('Illuminate\\Contracts\\Queue\\Factory');
     });
     $env = new Factory($resolver, $finder, $dispatcher);
     $env->setContainer($app);
     $env->share('app', $app);
     return new Illuminate($env);
 }
 /**
  * Register the view environment.
  *
  * @return void
  */
 public function registerFactory()
 {
     $this->app->singleton('view', function ($app) {
         // Next we need to grab the engine resolver instance that will be used by the
         // environment. The resolver will be used by an environment to get each of
         // the various engine implementations such as plain PHP or Blade engine.
         $resolver = $app['view.engine.resolver'];
         $finder = $app['view.finder'];
         $env = new Factory($resolver, $finder, $app['events']);
         // We will also set the container instance on this view environment since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $env->setContainer($app);
         $env->share('app', $app);
         return $env;
     });
 }
Ejemplo n.º 5
0
 /**
  * Set the IoC container instance.
  *
  * @param \Illuminate\Contracts\Container\Container $container
  * @return void 
  * @static 
  */
 public static function setContainer($container)
 {
     \Illuminate\View\Factory::setContainer($container);
 }
Ejemplo n.º 6
0
 /**
  * Register the view factory.
  */
 public function registerFactory()
 {
     $resolver = $this->container['view.engine.resolver'];
     $finder = $this->container['view.finder'];
     $factory = new Factory($resolver, $finder, $this->container['events']);
     $factory->setContainer($this->container);
     $this->viewFactory = $factory;
 }
 /**
  * @param Container $app
  */
 public function register(Container $app)
 {
     // we only need to do this if Blade views are enabled.
     if ($app['config']['view.blade.enabled']) {
         $app['blade.settings'] = $app['config']['view.blade.defaults'];
         $app['blade.template.paths'] = $app['blade.settings']['template_paths'];
         $app['files'] = function () {
             return new Filesystem();
         };
         $app['view.finder'] = function ($app) {
             return new FileViewFinder(new Filesystem(), $app['blade.template.paths']);
         };
         // create the Blade compiler using Filesystem and cache directory
         $app['blade.compiler'] = function ($app) {
             return new BladeCompiler(new Filesystem(), $app['blade.settings']['cache']);
         };
         // get a blade compiler engine instance
         $app['blade.engine'] = function ($app) {
             return new CompilerEngine($app['blade.compiler']);
         };
         $app['view.engine.resolver'] = function ($app) {
             $resolver = new EngineResolver();
             $resolver->register('php', function () {
                 return new PhpEngine();
             });
             $resolver->register('blade', function () use($app) {
                 return new CompilerEngine($app['blade.compiler'], $app['files']);
             });
             return $resolver;
         };
         $app['blade.factory'] = function ($app) {
             $view_factory = new IlluminateViewFactory($app['view.engine.resolver'], $app['view.finder'], $app['illuminate.events']);
             $view_factory->setContainer($app['nine.container']);
             return $view_factory;
         };
     }
 }
Ejemplo n.º 8
0
 /**
  * bindIlluminateView
  *
  * @param  Container  $app
  * @param  array      $viewPaths
  * @param  string     $cachePath
  * @return Container
  */
 public function bindIlluminateView(Container $app = null, array $viewPaths = array(), $cachePath)
 {
     if (!$app) {
         $app = new Container();
     }
     $this->ensureIlluminateBase($app);
     $app->bindShared('view.engine.resolver', function (Container $app) {
         $resolver = new EngineResolver();
         $resolver->register('php', function () {
             return new PhpEngine();
         });
         $app->bindShared('blade.compiler', function (Container $app) {
             $cache = $this->illuminateCachePath;
             return new BladeCompiler($app['files'], $cache);
         });
         $resolver->register('blade', function () use($app) {
             return new CompilerEngine($app['blade.compiler'], $app['files']);
         });
         return $resolver;
     });
     $app->bindShared('view.finder', function (Container $app) {
         $paths = $this->illuminateViewPaths;
         return new FileViewFinder($app['files'], $paths);
     });
     $app->bindShared('view', function (Container $app) {
         $env = new ViewFactory($app['view.engine.resolver'], $app['view.finder'], $app['events']);
         $env->setContainer($app);
         return $env;
     });
     return $app;
 }
Ejemplo n.º 9
0
 /**
  *
  * @return Factory
  */
 protected function getViewFactory()
 {
     $factory = new Factory($this->container['view.engine.resolver'], $this->container['view.finder'], $this->container['events']);
     $factory->setContainer($this->container);
     return $factory;
 }
Ejemplo n.º 10
0
 /**
  * Register the view factory. The factory is
  * available in all views.
  */
 protected function registerViewFactory()
 {
     // Register the View Finder first.
     $this->app->singleton('view.finder', function ($container) {
         return new ViewFinder($container['filesystem'], [], ['blade.php', 'scout.php', 'twig', 'php']);
     });
     $this->app->singleton('view', function ($container) {
         $factory = new Factory($container['view.engine.resolver'], $container['view.finder'], $container['events']);
         // Set the container.
         $factory->setContainer($container);
         // Tell the factory to also handle the scout template for backwards compatibility.
         $factory->addExtension('scout.php', 'blade');
         // Tell the factory to handle twig extension files and assign them to the twig engine.
         $factory->addExtension('twig', 'twig');
         // We will also set the container instance on this view environment since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $factory->setContainer($container);
         $factory->share('app', $container);
         return $factory;
     });
 }