Symfony 3 - how to inject the validator into a service?
<p>I try to inject the validator into my service - but I don't find it:</p>

<pre><code>mybundle.service.supplier:
     class: AppBundle\Service\SupplierService
     calls:
        - [setValidator, ['@validator']]
</code></pre>

<p>the @validator is not the expected RecursiveValidator <a href="http://api.symfony.com/3.1/Symfony/Component/Validator/Validator/RecursiveValidator.html" rel="noreferrer">http://api.symfony.com/3.1/Symfony/Component/Validator/Validator/RecursiveValidator.html</a> - the @validator is an interface.</p>

<p>So how can I inject the validator into my service?</p>

<p>This is what I want:</p>

<pre><code>&lt;?php

namespace AppBundle\Service;


use AppBundle\Entity\Supplier;
use AppBundle\Helper\EntityManagerTrait;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Validator\Validator\RecursiveValidator;

/**
 * Class SupplierService
 * @package AppBundle\Service
 */
class SupplierService
{
    use EntityManagerTrait;

   /** @var RecursiveValidator $validator */
    protected $validator;

    /**
     * @return RecursiveValidator
     */
    public function getValidator()
    {
        return $this-&gt;validator;
    }

    /**
     * @param RecursiveValidator $validator
     * @return SupplierService
     */
    public function setValidator($validator)
    {
        $this-&gt;validator = $validator;

        return $this;
    }


    public function addSupplier($data)
    {
        $supplier = new Supplier();
        $validator = $this-&gt;getValidator();
        $errors = $validator-&gt;validate($supplier);

    }
}
</code></pre>