Skip to content

configurable template paths #1135

@tacman

Description

@tacman

If the absolute path to the template is not passed to the Generator class, it defaults to looking in makerBundle's skeleton directory.

        if (!file_exists($templatePath)) {
            $templatePath = __DIR__.'/Resources/skeleton/'.$templateName;

What I'd like to do is set a list of paths to use when looking for a template in the config, e.g.

maker:
    root_namespace: Foo
    template_dirs: 
          - my/templates
          - vendor/symfony/maker-bundle/src/Resources/skeleton/twig

This would also allow my own makers to not require hardcoding the path or overriding the generator class. That is, if I have a make:something (MakeSomething.php), I'd like to be able to call

        $generator->generateClass(
            $extensionClassNameDetails->getFullName(),
            'Something.tpl.php',
            ['use_statements' => $useStatements]
        );

without having to prefix the template path myself with DIR . '../../skeleton/'.

Happy to do the PR if this approach seems worthwhile. I love the maker bundle, and use my own makers all the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions