sonata/twig error after symfony update 2.6 to 3.4

送分小仙女□ 提交于 2020-01-06 15:01:38

问题


im updating a project from sf2.6(php5.6) to sf3.4(php7.1)... its going well but now im stuck with an error i cant figure out how to fix it

error output: PHP message: PHP Fatal error: Uncaught Symfony\\Component\\Debug\\Exception\\FatalThrowableError: Type error: Argument 2 passed to Sonata\\FormatterBundle\\Formatter\\Pool::add() must implement interface Sonata\\FormatterBundle\\Formatter\\FormatterInterface, boolean given, called in /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php on line 4924 in /var/www/vendor/sonata-project/formatter-bundle/src/Formatter/Pool.php:43\nStack trace:\n#0 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(4924): Sonata\\FormatterBundle\\Formatter\\Pool->add('twig', true, NULL)\n#1 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(3475): ContainerMklcxqq\\appDevDebugProjectContainer->getSonata_Formatter_PoolService()\n#2 /var/www/var/cache/dev/ContainerMklcxqq/getAssetic_AssetManagerService.php(8): ContainerMklcxqq\\appDevDebugProjectContainer->getTwigService()\n#3 /var/www/var/cache/dev/ContainerMklcxqq/appDevDebugProjectContainer.php(1349): require('/var/www/var/ca...')\n#4 /v...\n'

if i check the mentioned line (4924) in the container i find:

$instance->add('twig', ${($_ = isset($this- >services['sonata.formatter.text.twigengine']) ? $this- 
>services['sonata.formatter.text.twigengine'] : $this- 
>getSonata_Formatter_Text_TwigengineService()) && false ?: '_'}, NULL);

when i check the actual service with "bin/console debug:container sonata.formatter.text.twigengine" i get the following, which is good, i guess:

Information for Service "sonata.formatter.text.twigengine"
==========================================================

 ---------------- ------------------------------------------------
  Option           Value
 ---------------- ------------------------------------------------
  Service ID       sonata.formatter.text.twigengine
  Class            Sonata\FormatterBundle\Formatter\TwigFormatter
  Tags             sonata.text.formatter
  Public           no
  Synthetic        no
  Lazy             no
  Shared           yes
  Abstract         no
  Autowired        no
  Autoconfigured   no
 ---------------- ------------------------------------------------

and finally i checked the actual TwigFormatter class, which leads to this post:

final class TwigFormatter implements FormatterInterface

how is this error possible and am i supposed to fix this or is any package update needed? im using the newest version of the sonata-project/formatter-bundle and also the newest version of twig/twig.

help and explanation is much appreciated. thanks guys.


回答1:


This bug comes from Symfony, see BUG: FormatterBundle\Formatter\Pool::add() must implement interface then [DI] Error on dumped container for inlined services

You'll have to wait for this fix to be merged, or if you're a player, apply it yourself.



来源:https://stackoverflow.com/questions/52622002/sonata-twig-error-after-symfony-update-2-6-to-3-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!