每天laravel-20160805| Container -8
2016-05-12 09:38
597 查看
/** * 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
相关文章推荐
- workerman结合laravel开发在线聊天应用的示例代码
- 简单对比分析Ruby on Rails 和 Laravel
- laravel安装zend opcache加速器教程
- 使用 PHPStorm 开发 Laravel
- 跟我学Laravel之请求与输入
- 跟我学Laravel之视图 & Response
- PHP IDE PHPStorm配置支持友好Laravel代码提示方法
- Laravel 5.0 发布 新版本特性详解
- 详解PHP的Laravel框架中Eloquent对象关系映射使用
- 深入解析PHP的Laravel框架中的event事件操作
- 推荐几款用 Sublime Text 开发 Laravel 所用到的插件
- Laravel中使用阿里云OSS Composer包分享
- Laravel 4 初级教程之Pages、表单验证
- Laravel框架表单验证详解
- Laravel框架中扩展函数、扩展自定义类的方法
- Laravel 4 初级教程之安装及入门
- laravel安装和配置教程
- PHP开发框架laravel安装与配置教程
- 跟我学Laravel之安装Laravel
- 跟我学Laravel之配置Laravel