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

Refactoring the code to be more MakerBundle-like #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

mamazu
Copy link
Collaborator

@mamazu mamazu commented Jan 2, 2025

What I did

  • Using the interact Method to set up the command
  • Using the DoctrineHelper to select entities interactively
  • Unifying the defaults for all commands (it's --assume-defaults or -d everywhere)

Changing naming conventions

  • Removing the option to configure namespaces for classes. If you don't like where the generator is putting things, just move them afterwards.
  • Using the class name details generator to generate Symfony like class names

What this means

One of the advantages of using Sulu is that you're free to put your classes where ever you want as long as they're correctly wired up. However, this also makes it harder for a tool like the maker bundle to find stuff to update and reference. So I suggest the following structure.

src
|--> Admin
|   +--> EventAdmin.php // The Admin configuration
|--> Controller
|   |--> Admin
|   |   +--> EventController.php // The Admin API controller
|   +--> OtherController.php // This is where Symfony maker controllers live
|--> Entity
|   +--> Event.php // The resource itself
+--> Trash
    +--> EventTrashItemHandler.php

@mamazu mamazu force-pushed the refactor branch 3 times, most recently from cb1088a to 2fd1660 Compare January 2, 2025 11:20
@mamazu
Copy link
Collaborator Author

mamazu commented Jan 2, 2025

@alexander-schranz Maybe you also have an opinion on the directory structure I'm proposing here. I don't know what the most common way to structure a Sulu application is.

@alexander-schranz
Copy link

I don't think our typical domain-based structure makes sense for a MakerBundle, so I would have a look at the Symfony MakerBundle how they handle it.

PS: would make all maker bundle classes @internal like Symfony Maker bundle is also doing. So you can at anytime refactor the whole code of a maker / generator.

@mamazu
Copy link
Collaborator Author

mamazu commented Jan 6, 2025

The file tree I showed in the comment would be the directory structure of the generated project. Because there is currently no convention for where a Sulu admin class would be located. It would generate admin classes with the maker to this location. src/Admin. Of course the user can still move them but I'm asking if this is a sensible default.

And marking all classes as internal makes sense.

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

Successfully merging this pull request may close these issues.

3 participants