Answer the question
In order to leave comments, you need to log in
How to fix "Given object is not an instance of the class this property was declared in" error?
Hello. I can't figure out why an error occurs when calling the flush()
method\Doctrine\ORM\EntityManagerInterface
<?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());
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question