Skip to content

Commit

Permalink
OrmExtension: every EntityManager has it's own RepositoryFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Jul 4, 2015
1 parent c4839d9 commit 2c574f1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Kdyby/Doctrine/DI/OrmExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class OrmExtension extends Nette\DI\CompilerExtension
),
'classMetadataFactory' => 'Kdyby\Doctrine\Mapping\ClassMetadataFactory',
'defaultRepositoryClassName' => 'Kdyby\Doctrine\EntityDao',
'repositoryFactoryClassName' => 'Kdyby\Doctrine\RepositoryFactory',
'queryBuilderClassName' => 'Kdyby\Doctrine\QueryBuilder',
'autoGenerateProxyClasses' => '%debugMode%',
'namingStrategy' => 'Doctrine\ORM\Mapping\UnderscoreNamingStrategy',
Expand Down Expand Up @@ -192,10 +193,6 @@ public function loadConfiguration()
->setImplement('Kdyby\Doctrine\EntityDaoFactory')
->setInject(FALSE)->setAutowired(TRUE);

$builder->addDefinition($this->prefix('repositoryFactory'))
->setClass('Kdyby\Doctrine\RepositoryFactory')
->setAutowired(FALSE);

$builder->addDefinition($this->prefix('schemaValidator'))
->setClass('Doctrine\ORM\Tools\SchemaValidator')
->setInject(FALSE);
Expand Down Expand Up @@ -328,6 +325,10 @@ protected function processEntityManager($name, array $defaults)
));
}

$builder->addDefinition($this->prefix($name . '.repositoryFactory'))
->setClass($config['repositoryFactoryClassName'])
->setAutowired(FALSE);

Validators::assertField($config, 'namespaceAlias', 'array');
Validators::assertField($config, 'hydrators', 'array');
Validators::assertField($config, 'dql', 'array');
Expand All @@ -349,7 +350,7 @@ protected function processEntityManager($name, array $defaults)
->addSetup('setClassMetadataFactoryName', array($config['classMetadataFactory']))
->addSetup('setDefaultRepositoryClassName', array($config['defaultRepositoryClassName']))
->addSetup('setQueryBuilderClassName', array($config['queryBuilderClassName']))
->addSetup('setRepositoryFactory', array($this->prefix('@repositoryFactory')))
->addSetup('setRepositoryFactory', array($this->prefix('@' . $name . '.repositoryFactory')))
->addSetup('setProxyDir', array($config['proxyDir']))
->addSetup('setProxyNamespace', array($config['proxyNamespace']))
->addSetup('setAutoGenerateProxyClasses', array($autoGenerateProxyClasses))
Expand Down

0 comments on commit 2c574f1

Please sign in to comment.