每天laravel-20160814| Container -17

来源:互联网 发布:软件项目案例 编辑:程序博客网 时间:2024/06/05 14:41
    /**     * Resolve all of the dependencies from the ReflectionParameters.     *     * @param  array  $parameters     * @param  array  $primitives     * @return array     */    // Resolve all of the dependencies from the ReflectionParameters.    protected function getDependencies(array $parameters, array $primitives = [])    {// if you want resolve the Dependencies ,first you need get it        $dependencies = [];// set a array dependencies        foreach ($parameters as $parameter) {// loop the parameters as parameter            $dependency = $parameter->getClass();// what ever get the Class name            // may set the name about the parameter            // If the class is null, it means the dependency is a string or some other            // primitive type which we can not resolve since it is not a class and            // we will just bomb out with an error since we have no-where to go.            if (array_key_exists($parameter->name, $primitives)) {// if the name in the primitives                $dependencies[] = $primitives[$parameter->name];// has the dependencies array            } elseif (is_null($dependency)) {// if is null                $dependencies[] = $this->resolveNonClass($parameter);// change the Non Class            } else {                $dependencies[] = $this->resolveClass($parameter);// resolveClass            }        }        return $dependencies;// ever thing done ,return the result    }
0 0
原创粉丝点击