public function __construct(ManagerRegistry
$managerRegistry, string
$entityManagerName = null
) { $this->managerRegistry =
$managerRegistry;
$this->entityManagerName =
$entityManagerName;
} final public function handle(Envelope
$envelope, StackInterface
$stack): Envelope
{ try { $entityManager =
$this->managerRegistry->
getManager($this->entityManagerName
);
} catch (\InvalidArgumentException
$e) { throw new UnrecoverableMessageHandlingException($e->
getMessage(), 0,
$e);
} return $this->
handleForManager($entityManager,
$envelope,
$stack);
} abstract protected function handleForManager(EntityManagerInterface
$entityManager, Envelope
$envelope, StackInterface
$stack): Envelope;
}