您的位置:首页 > 编程语言 > PHP开发

每天laravel-20160816| Container -19

2016-05-27 09:06 399 查看
/**
* If extra parameters are passed by numeric ID, rekey them by argument name.
*
* @param  array  $dependencies
* @param  array  $parameters
* @return array
*/
protected function keyParametersByArgument(array $dependencies, array $parameters)
{// this function is work for change the numeric ID key to string name key
foreach ($parameters as $key => $value) {// loop the parameters
if (is_numeric($key)) {// if a numeric
unset($parameters[$key]);// first unset it

$parameters[$dependencies[$key]->name] = $value;// then parameters return
// get the string key
}
}

return $parameters;
}

/**
* Register a new resolving callback.
*
* @param  string    $abstract
* @param  \Closure|null  $callback
* @return void
*/
public function resolving($abstract, Closure $callback = null)
{
if ($callback === null && $abstract instanceof Closure) {// if no callback and abstract is a Closure
$this->resolvingCallback($abstract);// get the call back,use another way to save it
} else {
$this->resolvingCallbacks[$this->normalize($abstract)][] = $callback;// save the function to the abstract
}
}// register a new function for callback

/**
* Register a new after resolving callback for all types.
*
* @param  string   $abstract
* @param  \Closure|null $callback
* @return void
*/
public function afterResolving($abstract, Closure $callback = null)
{// set the callback function used after resolve function done
if ($abstract instanceof Closure && $callback === null) {
$this->afterResolvingCallback($abstract);// if null, use other function
} else {
$this->afterResolvingCallbacks[$this->normalize($abstract)][] = $callback;
}// register the callback to the array store
}//
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: