title: How to inject a repository into a service in Symfony?
body: <p>I need to inject two objects into <code>ImageService</code>. One of them is an instance of <code>Repository/ImageRepository</code>, which I get like this: </p>
  
  <pre><code>$image_repository = $container-&gt;get('doctrine.odm.mongodb')
      -&gt;getRepository('MycompanyMainBundle:Image');
  </code></pre>
  
  <p>So how do I declare that in my services.yml? Here is the service:</p>
  
  <pre><code>namespace Mycompany\MainBundle\Service\Image;
  
  use Doctrine\ODM\MongoDB\DocumentRepository;
  
  class ImageManager {
      private $manipulator;
      private $repository;
  
      public function __construct(ImageManipulatorInterface $manipulator, DocumentRepository $repository) {
          $this-&gt;manipulator = $manipulator;
          $this-&gt;repository = $repository;
      }
  
      public function findAll() {
          return $this-&gt;repository-&gt;findAll();
      }
  
      public function createThumbnail(ImageInterface $image) {
          return $this-&gt;manipulator-&gt;resize($image-&gt;source(), 300, 200);
      }
  }
  </code></pre>