/** * Bind a new callback to an abstract's rebind event. * * @param string $abstract * @param \Closure $callback * @return mixed */ public function rebinding($abstract, Closure $callback)// means binding again { $this->reboundCallbacks[$this->normalize($abstract)][] = $callback;// set the callback function insert into the array store if ($this->bound($abstract)) {// if has bound function set return $this->make($abstract);// return the make result to what you want } } /** * Refresh an instance on the given target and method. * * @param string $abstract * @param mixed $target * @param string $method * @return mixed */ public function refresh($abstract, $target, $method)// refresh means to make or fire it again {// use the set target and method return $this->rebinding($this->normalize($abstract), function ($app, $instance) use ($target, $method) { $target->{$method}($instance); });// return the rebinding }//"function use" type way to import a closure function. // that will use a variable out the function, // the first good place i can see is reduce the parameters /** * Fire the "rebound" callbacks for the given abstract type. * * @param string $abstract * @return void */ protected function rebound($abstract)// start to run the rebound callbacks for the given abstract type { $instance = $this->make($abstract);// the make function is the get the instance of the ab foreach ($this->getReboundCallbacks($abstract) as $callback) {//loop the abstract to call it call_user_func($callback, $this, $instance);// call user function } }
每天laravel-20160808| Container -11
原创lijingsan1 博主文章分类:php ©著作权
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
每天laravel-20160815| Container -18
/** *
sed scala