简体   繁体   中英

How Symfony\Component\Validator\Validator could be properly injected into service?

I am trying to inject a validator class into my service.

My service.yml config:

validator_service:
        class: AppBundle\Service\Validator\ValidatorService
        argument: ['@validator']

But insted I got an error:

Catchable Fatal Error: Argument 1 passed to AppBundle\Service\Validator\ValidatorService::__construct() must be an instance of Symfony\Component\Validator\Validator, none given...

How can I properly inject a validator class into my service? What principles should I guide next time, to find proper name for injection (may be some tutorial, that I missed in symfony's docs)?

Thanks

它是“参数”,而不是“参数”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM