【发布时间】:2019-04-24 22:15:27
【问题描述】:
我使用 Symfony 3.4 并尝试将 Silex 应用程序迁移到它。所以我不能使用 Symfony 的自动装配。
我的 service.yml 看起来像
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: false
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: false
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
audit.persister.base:
class: MyBundle\Security\Audit\Persister\ChainedEntityTrailPersister
calls:
- method: 'addPersister'
argument:
- '@audit.persister_elasticsearch'
编译后的缓存类如下:
$this->services['audit.persister.base'] = $instance = new \MyBundle\Security\Audit\Persister\ChainedEntityTrailPersister();
$instance->addPersister();
我得到了错误:
Type error: Too few arguments to function MyBundle\Security\Audit\Persister\ChainedEntityTrailPersister::addPersister(), 0 passed in /var/www/html/api/var/cache/local/ContainerAdjsiif/getAudit_Persister_BaseService.php on line 14 and exactly 1 expected
错误是正确的。因为缓存的类创建者没有提供我在 config.xml 中设置的参数。
有人知道为什么参数不会设置在生成的缓存中吗?
【问题讨论】:
-
提示:缓存已清除。
标签: symfony service yaml symfony-3.4