среда, 13 марта 2019 г.

[MongoDB] [Symfony] "Could not find the document manager for class" fix with autowiring

For repository use this class below. Notice that it uses ManagerRegistry instead of Symfony\Bridge\Doctrine\RegistryInterface
<?php

use AppBundle\Document\Product;
use Doctrine\Bundle\MongoDBBundle\Repository\ServiceDocumentRepository;
use Doctrine\Bundle\MongoDBBundle\ManagerRegistry;

class ProductRepository extends ServiceDocumentRepository
{
    public function __construct(ManagerRegistry $managerRegistry)
    {
        parent::__construct($managerRegistry, Product::class);
    }
}

Комментариев нет:

Отправить комментарий