当我扩展ContainerAware或实现ContainerAwareInterface时,该服务不会调用setContainer.
class CustomService implements ContainerAwareInterface
{
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}
Run Code Online (Sandbox Code Playgroud)
如何在没有注射的情况下使用我服务的容器?是否需要将容器对象传递给构造函数或setter?
symfony ×1