entityManager = $locator; return $this; } /** * @return EntityManagerInterface */ public function getEntityManager() { if ($this->entityManager instanceof EntityManagerInterface) { return $this->entityManager; } if (null === $this->entityManager) { throw new \LogicException('Entity Manager locator was not set'); } $instance = call_user_func($this->entityManager); if (!$instance instanceof EntityManagerInterface) { throw new \LogicException(sprintf( 'Expects locator to return instance of "%s", got "%s"', EntityManagerInterface::class, is_object($instance) ? get_class($instance) : gettype($instance) )); } $this->entityManager = $instance; return $this->entityManager; } }