Skip to content

Commit

Permalink
Added support for user defined functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Mareš committed Feb 15, 2016
1 parent fc53c54 commit 42a9535
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/DI/DoctrineExtension.php
Expand Up @@ -56,7 +56,8 @@ class DoctrineExtension extends CompilerExtension
'proxyDir' => '%tempDir%/cache/proxies',
'ownEventManager' => FALSE,
'targetEntityMappings' => [],
'metadata' => []
'metadata' => [],
'functions' => []
];

private $entitySources = [];
Expand Down Expand Up @@ -130,7 +131,7 @@ public function beforeCompile()

$cache = $this->getCache($name, $builder);

$builder->getDefinition($name . ".config")
$configService = $builder->getDefinition($name . ".config")
->setFactory('\Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration', [
array_values($this->entitySources),
$config['debug'],
Expand All @@ -141,6 +142,17 @@ public function beforeCompile()
->addSetup('setNamingStrategy', ['@' . $name . '.naming']);


foreach ($config['functions'] as $functionName => $function) {
$configService->addSetup(
'addCustomStringFunction',
[
$functionName,
$function
]
);
}


foreach ($this->classMappings as $source => $target) {
$builder->getDefinition($name . '.resolver')
->addSetup('addResolveTargetEntity', [
Expand Down

0 comments on commit 42a9535

Please sign in to comment.