欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

每天laravel-20160820| ContextualBinding

程序员文章站 2022-04-18 11:01:55
...
concrete = $concrete;        $this->container = $container;// set the    }    /**     * 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 void     */    public function give($implementation)    {        $this->container->addContextualBinding($this->concrete, $this->needs, $implementation);    }// Define the implementation for the contextual binding}