Symfony2 LiipFunctionalTestBundle overriding @vali

2019-06-22 07:25发布

I am trying to inject @validator into my service but LiipFunctionalTestBundle is overriding that service when it gets injected.

admin.image_service:
    class: AdminBundle\Service\ImageService
    arguments: ["@validator", "@doctrine.orm.admin_entity_manager", "@image_storage_filesystem"]

Which results in the error

must be an instance of Symfony\Component\Validator\Validator\RecursiveValidator, instance of Liip\FunctionalTestBundle\Validator\DataCollectingValidator given

running php bin/console debug:container results in

liip_functional_test.validator: Liip\FunctionalTestBundle\Validator\DataCollectingValidator

validator: alias for "liip_functional_test.validator"

Is there a way to get around this over than remove liip and refactor all of my tests?

1条回答
2楼-- · 2019-06-22 07:46

In Your service you should typehint Interface not exact class.

Instdead Symfony\Component\Validator\Validator\RecursiveValidator use Symfony\Component\Validator\Validator\ValidatorInterface - which is implemented by both classes (Symfony and Liip).

查看更多
登录 后发表回答