Add a namespace to an already configured EntityManager

后端 未结 1 1680
南笙
南笙 2021-01-24 06:33

I\'ve got an EntityManager instance fully configured and working. The question is how to add an additional namespace to this EM?

$em->getConfiguration()->a         


        
1条回答
  •  梦毁少年i
    2021-01-24 07:06

    I managed to fix this issue, had to add the driver too:

    $namespace = 'My\GreatBundle\Entity';
    $configuration = $em->getConfiguration();
    $annotationDriver = new AnnotationDriver(
        $this->container->get('annotation_reader'),
        [__DIR__ . '/../Entity']
    );
    
    /** @var MappingDriverChain $driver */
    $driver = $configuration->getMetadataDriverImpl();
    $driver->addDriver($annotationDriver, $namespace);
    
    $configuration->addEntityNamespace('MyGreatBundle', $namespace);
    

    0 讨论(0)
提交回复
热议问题