【发布时间】:2022-01-27 13:02:05
【问题描述】:
如何在 Nette 中从演示者(控制器)/内部检索模型、模板的服务?
【问题讨论】:
标签: php dependency-injection inversion-of-control ioc-container nette
如何在 Nette 中从演示者(控制器)/内部检索模型、模板的服务?
【问题讨论】:
标签: php dependency-injection inversion-of-control ioc-container nette
自动装配(依赖注入)- How to autowire ( autowiring ) / get services in Nette from the di dependency injection container context
在 Presenter 内部通过 $this->getRouter()、$this->getAction() 等通过这种传递关系访问它
在 Latte 模板中作为 $presenter 变量、$presenter->getRouter() 等方法链接,分别为 $presenter->getContext(),它已被弃用,因此如果必须通过模板分配这样的方法链接不可传递访问变量
【讨论】: