我试图在服务中输出的html内容。尝试使用Html5 5-转换器。转换器在我的服务中加载。我试过以下几点:
php
$body = $content->getFieldValue('body')->xml;
$html = $html5Converter->convert($body);我得到了一个例外: LogicExceptionRendering片段只能在处理请求时才能完成
问候
发布于 2015-12-10 11:53:19
您的代码可能不在request范围内运行(请参阅Symfony文档中有关此问题的更多信息)。例如,您可以在控制台命令中使用依赖于request服务的服务。
检查服务的依赖关系,您可以通过在容器中放置空的Request,然后调用\Symfony\Component\DependencyInjection\ContainerInterface::enterScope('request')来模拟范围。
https://stackoverflow.com/questions/34200790
复制相似问题