Skip to content

Commit 33ccd35

Browse files
jlagneaudunglas
authored andcommitted
Make namespaces aliases possible.
1 parent 6c9f8a3 commit 33ccd35

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/TypesGenerator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,11 @@ private function generateClassUses(array $annotationGenerators, array $classes,
827827
*/
828828
private function namespaceToDir(array $config, string $namespace): string
829829
{
830+
if (!empty($config['namespaces']['alias'])) {
831+
foreach ($config['namespaces']['alias'] as $a) {
832+
$namespace = str_replace($a['namespace'], $a['path'], $namespace);
833+
}
834+
}
830835
return sprintf('%s/%s/', $config['output'], strtr($namespace, '\\', '/'));
831836
}
832837

src/TypesGeneratorConfiguration.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ function ($rdfa) {
9292
->addDefaultsIfNotSet()
9393
->info('PHP namespaces')
9494
->children()
95+
->arrayNode('alias')
96+
->cannotBeOverwritten()
97+
->prototype('array')
98+
->children()
99+
->scalarNode('namespace')
100+
->defaultNull()
101+
->info('Namespace to alias')
102+
->example('App\\')
103+
->end()
104+
->scalarNode('path')
105+
->defaultNull()
106+
->info('Path to alias')
107+
->example('src/')
108+
->end()
109+
->end()
110+
->end()
111+
->end()
95112
->scalarNode('entity')->defaultValue('AppBundle\Entity')->info('The namespace of the generated entities')->example('Acme\Entity')->end()
96113
->scalarNode('enum')->defaultValue('AppBundle\Enum')->info('The namespace of the generated enumerations')->example('Acme\Enum')->end()
97114
->scalarNode('interface')->defaultValue('AppBundle\Model')->info('The namespace of the generated interfaces')->example('Acme\Model')->end()

0 commit comments

Comments
 (0)