share() public method

Add a piece of shared data to the factory.
public share ( string $key, mixed $value = null ) : void
$key string
$value mixed
return void
 /**
  * Copied from the view service provider...
  *
  * Register the view factory.
  *
  * @return void
  */
 public function registerFactory()
 {
     $this->app['view'] = $this->app->share(function ($app) {
         // Next we need to grab the engine resolver instance that will be used by the
         // factory. The resolver will be used by a factory to get each of
         // the various engine implementations such as plain PHP or Blade engine.
         $resolver = $app['view.engine.resolver'];
         $finder = $app['view.finder'];
         $factory = new View\Factory($resolver, $finder, $app['events'], $app['presenter.decorator']);
         // We will also set the container instance on this view factory since the
         // view composers may be classes registered in the container, which allows
         // for great testable, flexible composers for the application developer.
         $factory->setContainer($app);
         $factory->share('app', $app);
         return $factory;
     });
 }