Как внедрить репозиторий в сервис в Symfony?

Мне нужно ввести два объекта вImageService, Один из них является примеромRepository/ImageRepository, который я получаю так:

$image_repository = $container->get('doctrine.odm.mongodb')
    ->getRepository('MycompanyMainBundle:Image');

Итак, как мне объявить это в моих services.yml? Вот услуга:

namespace Mycompany\MainBundle\Service\Image;

use Doctrine\ODM\MongoDB\DocumentRepository;

class ImageManager {
    private $manipulator;
    private $repository;

    public function __construct(ImageManipulatorInterface $manipulator, DocumentRepository $repository) {
        $this->manipulator = $manipulator;
        $this->repository = $repository;
    }

    public function findAll() {
        return $this->repository->findAll();
    }

    public function createThumbnail(ImageInterface $image) {
        return $this->manipulator->resize($image->source(), 300, 200);
    }
}

Ответы на вопрос(5)

Ваш ответ на вопрос