每天laravel-20160812|Container-15
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了每天laravel-20160812|Container-15,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3014字,纯文字阅读大概需要5分钟。
内容图文
/** * Resolve the given type from the container. * * @param string $abstract * @param array $parameters * @return mixed */ // get the given type from the containerpublic function make($abstract, array $parameters = []){// this function name "make" like compile c file to binary file in the linux $abstract = $this->getAlias($this->normalize($abstract)); // first get the alias as the new name // If an instance of the type is currently being managed as a singleton we'll // just return an existing instance instead of instantiating new instances // so the developer can keep using the same objects instance every time. if (isset($this->instances[$abstract])) { return $this->instances[$abstract]; }// like normal method // if it is exist ,we will return it, that ok; $concrete = $this->getConcrete($abstract);// concrete like create it done // We're ready to instantiate an instance of the concrete type registered for // the binding. This will instantiate the types, as well as resolve any of // its "nested" dependencies recursively until all have gotten resolved. if ($this->isBuildable($concrete, $abstract)) {// isBuildable $object = $this->build($concrete, $parameters);// check it is can be Builda } else { $object = $this->make($concrete, $parameters); } // If we defined any extenders for this type, we'll need to spin through them // and apply them to the object being built. This allows for the extension // of services, such as changing configuration or decorating the object. foreach ($this->getExtenders($abstract) as $extender) { $object = $extender($object, $this); }// to though , a extender done is too trouble // If the requested type is registered as a singleton we'll want to cache off // the instances in "memory" so we can return it later without creating an // entirely new instance of an object on each subsequent request for it. if ($this->isShared($abstract)) { $this->instances[$abstract] = $object; }// get the instance from the "memory" $this->fireResolvingCallbacks($abstract, $object); $this->resolved[$abstract] = true; return $object;}// in the last we will found it is a compatible way to get you want object./** * Get the concrete type for a given abstract. * * @param string $abstract * @return mixed $concrete */protected function getConcrete($abstract){// get a Concrete type for a abstract if (! is_null($concrete = $this->getContextualConcrete($abstract))) { return $concrete; }// if you can get it ,then return it // otherwise see next // If we don't have a registered resolver or concrete for the type, we'll just // assume each type is a concrete name and will attempt to resolve it as is // since the container should be able to resolve concretes automatically. if (! isset($this->bindings[$abstract])) { return $abstract; }// return it back return $this->bindings[$abstract]['concrete'];}//last we will binding it
内容总结
以上是互联网集市为您收集整理的每天laravel-20160812|Container-15全部内容,希望文章能够帮你解决每天laravel-20160812|Container-15所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。