Slim 框架学习,第二天
2017-11-29 21:18
239 查看
紧接着第一天的内容
今天主要说下,App类中的map 方法 中的route=this->container->get(‘router’)->map(methods,pattern, $callable);
该方法。
跳转过程
Container 类 public function get($id) { if (!$this->offsetExists($id)) { throw new ContainerValueNotFoundException(sprintf('Identifier "%s" is not defined.', $id)); } try { return $this->offsetGet($id); } catch (\InvalidArgumentException $exception) { if ($this->exceptionThrownByContainer($exception)) { throw new SlimContainerException( sprintf('Container error while retrieving "%s"', $id), null, $exception ); } else { throw $exception; } } }
路径 vendor/pimple/pimple/src/Pimple/Container.php public function offsetGet($id) { if (!isset($this->keys[$id])) { throw new UnknownIdentifierException($id); } if ( isset($this->raw[$id]) || !is_object($this->values[$id]) || isset($this->protected[$this->values[$id]]) || !method_exists($this->values[$id], '__invoke') ) { return $this->values[$id]; } if (isset($this->factories[$this->values[$id]])) { return $this->values[$id]($this); } $raw = $this->values[$id]; $val = $this->values[$id] = $raw($this); $this->raw[$id] = $raw; $this->frozen[$id] = true; return $val; }
在这里返回了router 对象,其中 val=this->values[id]=raw($this); 没有看太明白。
这里牵扯到了一个类,就是 DefaultServicesProvider,这里是他的服务提供者类。需要重点理解下。
明天重点工作,研究DefaultServicesProvider的实现原理。
相关文章推荐
- 4月9号(公司的BI系统框架学习第二天)
- Slim 框架学习,第八天 _Container(五)
- Slim 框架学习,第六天 _Container(三)
- PHP再学习4—— slim框架学习和使用
- Slim 框架学习,第三天
- Slim 框架学习,第四天
- Slim 框架学习,第一天
- Slim 框架学习,第十五天 _Router(六)
- mybaitis学习第二天 mybatis框架原理
- Slim 框架学习,第九天 _Container(六)
- YII框架学习 第二天(1) 控制器分析 和 布局模板
- YII框架学习 第二天(2) gii 和 模块
- Slim 框架学习,第七天 _Container(四)
- 学习ASP.NET MVC5的一个轻量级的NinJect框架学习的第二天
- Slim 框架学习,第十天 _Router(一)
- Slim 框架学习,第十九天 _Router(十)
- Slim 框架学习,第二十天 _Router(十一)
- Struts2 框架学习第二天笔记
- Slim 框架学习,第四天 _Container(一)
- Slim 框架学习,第十八天 _Router(九)