diff --git a/src/Command/GenerateTypesCommand.php b/src/Command/GenerateTypesCommand.php index 869baa39..b2a080e0 100644 --- a/src/Command/GenerateTypesCommand.php +++ b/src/Command/GenerateTypesCommand.php @@ -146,7 +146,10 @@ protected function execute(InputInterface $input, OutputInterface $output): void $goodRelationsBridge = new GoodRelationsBridge($relations); $cardinalitiesExtractor = new CardinalitiesExtractor($graphs, $goodRelationsBridge); - $loader = new \Twig_Loader_Filesystem(__DIR__.'/../../templates/'); + $templatePaths = $processedConfiguration['generatorTemplates']; + $templatePaths[] = __DIR__.'/../../templates/'; + + $loader = new \Twig_Loader_Filesystem($templatePaths); $twig = new \Twig_Environment($loader, ['autoescape' => false, 'debug' => $processedConfiguration['debug']]); $twig->addFilter(new \Twig_SimpleFilter('ucfirst', 'ucfirst')); $twig->addFilter(new \Twig_SimpleFilter('pluralize', [Inflector::class, 'pluralize'])); diff --git a/src/TypesGeneratorConfiguration.php b/src/TypesGeneratorConfiguration.php index d1a3b29a..29cd12f6 100644 --- a/src/TypesGeneratorConfiguration.php +++ b/src/TypesGeneratorConfiguration.php @@ -209,6 +209,10 @@ function ($rdfa) { ]) ->prototype('scalar')->end() ->end() + ->arrayNode('generatorTemplates') + ->info('Directories for custom generator twig templates') + ->prototype('scalar')->end() + ->end() ->end(); return $treeBuilder; diff --git a/tests/Command/DumpConfigurationTest.php b/tests/Command/DumpConfigurationTest.php index 7e1c27da..5ee5c53a 100644 --- a/tests/Command/DumpConfigurationTest.php +++ b/tests/Command/DumpConfigurationTest.php @@ -199,6 +199,9 @@ interface: null - ApiPlatform\SchemaGenerator\AnnotationGenerator\ConstraintAnnotationGenerator - ApiPlatform\SchemaGenerator\AnnotationGenerator\SerializerGroupsAnnotationGenerator + # Directories for custom generator twig templates + generatorTemplates: [] + YAML ,