@@ -33,6 +33,7 @@ public function __construct(
33
33
private string $ namespacePrefix ,
34
34
?PhpCompatUtil $ phpCompatUtil = null ,
35
35
private ?TemplateComponentGenerator $ templateComponentGenerator = null ,
36
+ private array $ templatesFolders = [],
36
37
) {
37
38
$ this ->twigHelper = new GeneratorTwigHelper ($ fileManager );
38
39
$ this ->namespacePrefix = trim ($ namespacePrefix , '\\' );
@@ -299,11 +300,7 @@ private function addOperation(string $targetPath, string $templateName, array $v
299
300
300
301
$ templatePath = $ templateName ;
301
302
if (!file_exists ($ templatePath )) {
302
- $ templatePath = \sprintf ('%s/templates/%s ' , \dirname (__DIR__ ), $ templateName );
303
-
304
- if (!file_exists ($ templatePath )) {
305
- $ templatePath = $ this ->getTemplateFromLegacySkeletonPath ($ templateName );
306
- }
303
+ $ templatePath = $ this ->getTemplatePath ($ templatePath );
307
304
308
305
if (!file_exists ($ templatePath )) {
309
306
throw new \Exception (\sprintf ('Cannot find template "%s" in the templates/ dir. ' , $ templateName ));
@@ -316,6 +313,25 @@ private function addOperation(string $targetPath, string $templateName, array $v
316
313
];
317
314
}
318
315
316
+ private function getTemplatePath (string $ templateName ): string
317
+ {
318
+ foreach ($ this ->templatesFolders as $ folder ) {
319
+ $ templatePath = \sprintf ('%s/%s ' , $ folder , $ templateName );
320
+
321
+ if ($ this ->fileManager ->fileExists ($ templatePath )) {
322
+ return $ templatePath ;
323
+ }
324
+ }
325
+
326
+ $ templatePath = \sprintf ('%s/templates/%s ' , \dirname (__DIR__ ), $ templateName );
327
+
328
+ if (!file_exists ($ templatePath )) {
329
+ return $ this ->getTemplateFromLegacySkeletonPath ($ templateName );
330
+ }
331
+
332
+ return $ templatePath ;
333
+ }
334
+
319
335
/**
320
336
* @legacy - Remove when public generate methods become "internal" to MakerBundle in v2
321
337
*/
0 commit comments