/** * 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 } }
This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1774193
Daily laravel-20160808| Container-11