application level error after symfony update to 3.4
今天我从 sf2.8 升级到 sf3.4...首先我遇到了一些错误,因为我没有重新编写 sf 标准文件,现在这些错误消失了,我遇到了应用程序级别的错误。在 sf2.8 下这不是问题,我不明白为什么现在是这样。
错误触发命中 "/":
outing\\\
outer, instance of Symfony\\\\Bundle\\\\FrameworkBundle\\\
outing\\\
outer given, called in /var/www/var/cache/dev/ContainerV5bxhc0/appDevDebugProjectContainer.php on line 3678 in /var/www/src/TheApp/FrontendBundle/Services/UrlAliasService.php:25\
Stack trace:\
#0 /var/www/var/cache/dev/ContainerV5bxhc0/appDevDebugProjectContainer.php(3678): TheApp\\\\FrontendBundle\\\\Services\\\\UrlAliasService->__construct(Object(Doctrine\\\\ORM\\\\EntityManager), Object(Symfony\\\\Bundle\\\\FrameworkBundle\\\
outing\\\
outer), Object(Cocur\\\\Slugify\\\\Slugify))\
#1 /var/www/var/cache/dev/ContainerV5bxhc0/appDevDebugProjectContainer.php(3698): ContainerV5bxhc0\\\\appDevDebugProjectContainer->getTheApp_UrlaliasserviceService()\
#2 /var/www/var/cache/dev/ContainerV5bxhc0/appDevDebugProjectContainer.php(3872): Contain...\
'
所以服务 "UrlAliasService" 需要 3 个参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 | ... use TheApp\\FrontendBundle\ outing\ outer; ... public function __construct(EntityManager $entityManager, Router $router, Slugify $slugify) { $this->em = $entityManager; $this->urlRepository = $this->em->getRepository('TheAppFrontendBundle:UrlAlias'); $this->router = $router; $this->slugify = $slugify; $this->urlAliasInProcess = new ArrayCollection(); } |
这 3 个参数被连接到 services.yml:
1 2 3 | theapp.urlaliasservice: class: TheApp\\FrontendBundle\\Services\\UrlAliasService arguments: ["@doctrine.orm.entity_manager","@router","@cocur_slugify"] |
这里是路由器类,扩展 BaseRouter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | namespace TheApp\\FrontendBundle\ outing; use Symfony\\Bundle\\FrameworkBundle\ outing\ outer as BaseRouter; ... use Symfony\\Component\ outing\ equestContext; class Router extends BaseRouter implements ContainerAwareInterface { private $container; public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null) { parent::__construct($container, $resource, $options, $context); $this->setContainer($container); } public function getGenerator() { $generator = parent::getGenerator(); $generator->setContainer($this->container); return $generator; } public function setContainer(ContainerInterface $container = null) { $this->container = $container; } } |
所以错误告诉我传入的参数来自类型 TheApp\\\\\\\\FrontendBundle\\\\
郊游\\\\
外部 .... 但它实际上来自 Symfony\\\\\\\\Bundle\\\\\\\\FrameworkBundle\\\\ 类型
郊游\\\\
外部....阅读代码这个错误没有意义吧?类 TheApp\\\\\\\\FrontendBundle\\\\
郊游\\\\
外部扩展 Symfony\\\\\\\\Bundle\\\\\\\\FrameworkBundle\\\\
郊游\\\\
外部那么它怎么可能不是它的一个实例呢?非常非常感谢帮助和解释。
很明显
outing\
outer