Skip to content

[make:entity] better repo methods #1312

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

Closed
wants to merge 1 commit into from

Conversation

jrushlow
Copy link
Collaborator

@jrushlow jrushlow commented May 23, 2023

  • repositories are generated with persist(...), persistAndFlush(...), remove(...), removeAndFlush(...) & flush() methods.

  • legacy save(...) & remove(...) methods may be generated instead by passing the --legacy-methods option to make:entity

The legacy option is used to provide consistency in projects that already have repositories with the save() && remove() methods. However, we strongly encourage projects not to use --legacy-methods as it is deprecated and will be removed in a future version of MakerBundle.

The legacy option is not available with make:user or make:reset-password to improve code base maintainability.

@jrushlow jrushlow added Feature New Feature Status: Needs Work Additional work is needed labels May 23, 2023
@jrushlow jrushlow mentioned this pull request May 23, 2023
@jrushlow
Copy link
Collaborator Author

We could generate these methods in a RepositoryMethodsTrait::class and import them in each repo. This would keep the generated repos DRY and essentially empty of code. The downside would be we xor the user would have to handle any static analysis complaints. The method signatures would be something like RepositoryMethodsTrait::persistAndFlush(object $entity): void.

Thoughts?

@sadikoff
Copy link
Contributor

what if propose this trait for DoctrineBundle? I'm not sure that generating these methods is a good plan?

@weaverryan weaverryan closed this Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Work Additional work is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants