<?phpnamespace illuminate\container;use illuminate\contracts\container\contextualbindingbuilder as ContextualBindingBuilderContract;class ContextualBindingBuilder implements contextualbindingbuildercontract{ /** * the underlying container instance. * * @ var \illuminate\container\container */ protected $container;// the underlying container instance /** * The concrete instance. * * @var string */ protected $concrete;// a instance about concrete /** * the abstract target. * * @var string */ protected $needs;// a target about the Abstract /** * create a new contextual binding builder. * * @param \Illuminate\Container\Container $container * @param string $concrete * @return void */ public function __construct (Container $container, $ Concrete) { $this->concrete = $concrete; $this->container = $container;// set the &nbsP; } /** * define the abstract target that depends on the context. * * @param string $abstract * @ return $this */ public function needs ($ abstract) { $this->needs = $abstract; return $this; }// Function is needs /** * define the implementation for the contextual binding. * * @param \Closure|string $implementation * @return &nbsP;void */ public function give ($implementation) { $this->container-> Addcontextualbinding ($this->concrete, $this->needs, $implementation); } define the implementation for the contextual binding}
This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1785393
Daily laravel-20160820| Contextualbinding