Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Allow custom Generator class in MakerInterface #1567

Open
serotoninja opened this issue May 25, 2024 · 0 comments
Open

Feature Request: Allow custom Generator class in MakerInterface #1567

serotoninja opened this issue May 25, 2024 · 0 comments

Comments

@serotoninja
Copy link

I would like to propose an enhancement to the symfony/maker-bundle to allow the use of a custom Generator class in the Makers that implement the MakerInterface. This change would provide greater flexibility in creating classes in the desired namespaces and paths.

Currently, the MakerInterface defines the generate method as follows:

public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator);

In this setup, the Generator class is tightly coupled with AutoloaderUtil, limiting customization options for generating files in specific namespaces and paths.

Proposed Change:

I suggest modifying the MakerInterface to accept a GeneratorInterface instead of a Generator. This would allow developers to implement their own Generator class that fits their specific needs.

The new MakerInterface would look like this:

interface MakerInterface
{
    //...
    public function generate(InputInterface $input, ConsoleStyle $io, GeneratorInterface $generator);
}

Benefits:

  • Flexibility: Developers can create and use their own Generator implementations to generate files in customized paths and namespaces.
  • Decoupling: Reduces dependency on AutoloaderUtil, making the codebase more modular and easier to maintain.
  • Extensibility: Encourages the creation of more complex and tailored file generation logic without modifying the core bundle.

Implementation Considerations:

  • Introduce a GeneratorInterface that Generator implements.
  • Update the existing Maker classes to use the new GeneratorInterface.
  • Ensure backward compatibility for existing makers by providing a default implementation of the GeneratorInterface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant