我有这段代码
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" }
在 2.8 及以下版本中这个方法运行良好,但是在 3.0 版本中我遇到了如下错误信息:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] The file "/ext/thing/app/config/services.yml" does not contain valid YAML.
[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
文件中没有其他内容。
arguments: ['@repo.game']
,它就应该通过。 - qooplmao双引号/单引号
的情况... "在我看来,使用单引号比双引号更容易:在Yaml中,双引号需要转义字符串中的许多字符,而单引号只需要转义单引号本身(通过将它们加倍)"(摘自https://github.com/symfony/symfony-demo/issues/246#issuecomment-157686459) - qooplmao