I am new in symfony, and I see in the documents, that I can get and use validator service in the controller like:

$this->get('validator');

what is the right\easy way to get the validator service in my own service class that i wrote

thank you

有帮助吗?

解决方案

inject it into the service like this

your.service:
    class: Path\To\Your\Service
    arguments: [@validator]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top