我有这个代码
services:
repo.game:
class: Doctrine\ORM\EntityRepository
factory_service: doctrine.orm.default_entity_manager
factory_method: getRepository
arguments:
- AppBundle\Entity\Game
file.upload.listener:
class: AppBundle\Listener\FileUploadListener
arguments: [@repo.game]
tags:
- { name: "kernel.event_listener", event: "oneup_uploader.post_upload", method: "onUpload" }
这在
[Symfony\Component\Yaml\Exception\ParseException]The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at line 14 (near "arguments: [@repo.game]").
我的
/ext/thing/app/config/services.yml
文件中没有其他内容 最佳答案
引用 yaml section 中的升级指南:
所以尝试修改你的配置如下:
file.upload.listener:
class: AppBundle\Listener\FileUploadListener
arguments: ["@repo.game"]
tags:
- { name: "kernel.event_listener", event: "oneup_uploader.post_upload", method: "onUpload" }
希望这有帮助
关于php - Symfony 3, DI - 将服务添加到参数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34069477/