pro-dev
@pro-dev

Как исправить ошибку «Given object is not an instance of the class this property was declared in»?

Всем привет. Не могу понять почему возникает ошибка при вызове метода flush() у \Doctrine\ORM\EntityManagerInterface

60c0b072bd7f8528490204.png

<?php

declare(strict_types=1);

namespace App\Shared;

use Doctrine\ORM\EntityManagerInterface;

class Flusher
{
    private EntityManagerInterface $em;
    private EventDispatcher $dispatcher;

    public function __construct(EntityManagerInterface $em, EventDispatcher $dispatcher)
    {
        $this->em = $em;
        $this->dispatcher = $dispatcher;
    }

    public function flush(AggregateRoot ...$roots): void
    {
        dump($roots);
        $this->em->flush();

        foreach ($roots as $root) {
            $this->dispatcher->dispatch($root->releaseEvents());
        }
    }
}


В чём может быть проблема?

Doctrine: v2.8.3
Symfony: v5.2.6
  • Вопрос задан
  • 211 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы