码迷,mamicode.com
首页 > 其他好文 > 详细

每天laravel-20160816| Container -19

时间:2016-05-27 15:06:24      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:function   change   return   

/**
 * 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
}//


本文出自 “专注php” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1783715

每天laravel-20160816| Container -19

标签:function   change   return   

原文地址:http://jingshanls.blog.51cto.com/3357095/1783715

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!