Dependency injection 如何将模板注入symfony4服务
我有一个symfony4服务,需要模板。我可以注入其他服务,如Dependency injection 如何将模板注入symfony4服务,dependency-injection,symfony4,Dependency Injection,Symfony4,我有一个symfony4服务,需要模板。我可以注入其他服务,如 use Psr\Log\LoggerInterface; 在服务构造函数中 public function __construct(LoggerInterface $logger) { $this->logger = $logger; } public function __construct(Environment $templating, LoggerInterface $logger) {
use Psr\Log\LoggerInterface;
在服务构造函数中
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
public function __construct(Environment $templating, LoggerInterface $logger)
{
$this->templating = $templating;
$this->logger = $logger;
}
我应该导入哪个类?我找到了如何获取模板组件
使用细枝\环境代码>
这就是我的班级现在的样子
在构造函数中
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
public function __construct(Environment $templating, LoggerInterface $logger)
{
$this->templating = $templating;
$this->logger = $logger;
}