managerRegistry = $managerRegistry; } public function getDefaultManager(): EntityManagerInterface { return $this->getManager($this->managerRegistry->getDefaultManagerName()); } public function getManager(string $name): EntityManagerInterface { $em = $this->managerRegistry->getManager($name); if ($em instanceof EntityManagerInterface) { return $em; } throw new RuntimeException( sprintf( 'Only managers of type "%s" are supported. Instance of "%s given.', EntityManagerInterface::class, get_class($em) ) ); } }