每天laravel-20160805| Container -8
2016-05-12 09:37
525 查看
/** * Register an existing instance as shared in the container. * * @param string $abstract * @param mixed $instance * @return void */ public function instance($abstract, $instance)// Register an existing instance as shared in the container. { $abstract = $this->normalize($abstract);// get a normal string. // First, we will extract the alias from the abstract if it is an array so we // are using the correct name when binding the type. If we get an alias it // will be registered with the container so we can resolve it out later. if (is_array($abstract)) {// check it is a array list($abstract, $alias) = $this->extractAlias($abstract);// list the array to the variable. // like extract function $this->alias($abstract, $alias);// set alias by abstract and alias } // First, we will extract the alias from the abstract if it is an array. // so we are using the correct name when binding the type. // if we get an alias it will be registered the container so we can resolve it out later. unset($this->aliases[$abstract]);// un set the aliases by key ,the key is abstract class. // We'll check to determine if this type has been bound before, and if it has // we will fire the rebound callbacks registered with the container and it // can be updated with consuming classes that have gotten resolved here. $bound = $this->bound($abstract); // we will check to determine if this type has been bound before, // and if it has we will fire the rebound callbacks registered with the container // and it can be updated with consuming classes that have gotten resolved here. $this->instances[$abstract] = $instance;// set instance if ($bound) { $this->rebound($abstract);// if it is bound ,use the rebound function. } }// last we has a summary // this function has two base action // one is abstract,other is bounding // set the instance and alias
相关文章推荐
- phpcms头部代码详细分析
- Yii2 return redirect()
- phpcms v9 修改文件时空白
- yii2带搜索功能的下拉框实例详解
- 黄聪:PHP解决textarea内容换行存入数据库,如何解析取出不能自动换行
- PHP简单工厂设计模式,简单代码。(缺点请指正,互相学习)
- PHP学习心路历程
- PHP中抽象类与接口的区别
- php通过iframe实现局部刷新
- Thinkphp 生成的验证码不显示问题解决
- yii2带搜索功能的下拉框实例详解
- php ucwords() 函数将字符串中每个单词的首字符转换为大写(实现代码)
- php使用文本统计访问量的方法
- PHP 的比较运算与逻辑运算详解
- php反射类ReflectionClass用法分析
- php使用curl并发减少后端访问时间的方法分析
- php similar_text()函数的定义和用法
- PHP数组函数知识汇总
- Ubuntu16.04 php5安装失败解决方案
- php 原来时间加一天、一时.、一年