kayue / KayueWordpressBundle

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).
101 stars 43 forks source link

Reconfigure em to avoid mapping collision with default em #52

Closed umpirsky closed 10 years ago

umpirsky commented 10 years ago

I tried:

$config = clone $this->defaultEntityManager->getConfiguration();
$config->addEntityNamespace('KayueWordpressBundle', 'Kayue\WordpressBundle\Entity');

But I get same error, because driver is reused.

This way it works with no errors.

If see you tweak cache:

$em->getMetadataFactory()->setCacheDriver($this->getCacheImpl('metadata_cache', $this->currentBlogId));
$em->getConfiguration()->setQueryCacheImpl($this->getCacheImpl('query_cache', $this->currentBlogId));
$em->getConfiguration()->setResultCacheImpl($this->getCacheImpl('result_cache', $this->currentBlogId));

We can always set cache from default config:

$config->setMetadataCacheImpl($this->defaultEntityManager->getConfiguration()->getMetadataCacheImpl());
$config->setQueryCacheImpl($this->defaultEntityManager->getConfiguration()->getQueryCacheImpl());
$config->setResultCacheImpl($this->defaultEntityManager->getConfiguration()->getResultCacheImpl());
kayue commented 10 years ago

@umpirsky Thanks, this is perfect.

umpirsky commented 10 years ago

:+1: