标签:laravel
/** * 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 } }
本文出自 “专注php” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1774193
每天laravel-20160808| Container -11
标签:laravel
原文地址:http://jingshanls.blog.51cto.com/3357095/1774193