-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
Add a simple way to use the new service entity repository #330
Add a simple way to use the new service entity repository #330
Conversation
b52eb7b
to
9d5df06
Compare
|
Co-authored-by: Łukasz Chruściel <lchrusciel@gmail.com>
8f1046c
to
4f8f809
Compare
I think it has to be here too |
@@ -70,3 +70,5 @@ services: | |||
- | |||
name: doctrine.event_subscriber | |||
connection: default | |||
|
|||
App\Repository\ComicBookRepository: null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't App\Repository\ComicBookRepository: ~
work as well? It looks better, definitely 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but Symfony best practice is to set "null" instead of "~"
https://github.com/symfony/recipes/#validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* @method QueryBuilder createQueryBuilder(string $alias, string $indexBy = null) | ||
* @method ?object find($id, $lockMode = null, $lockVersion = null) | ||
*/ | ||
trait ResourceRepositoryTrait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be awesome, is to create php unit test for this trait with usage of anonymous class. But I can live with the current solution. Also, it appears that it may be cumbersome to do such a test
* @property ClassMetadata $_class | ||
* | ||
* @method QueryBuilder createQueryBuilder(string $alias, string $indexBy = null) | ||
* @method ?object find($id, $lockMode = null, $lockVersion = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we shouldn't declare these methods as abstract, to force contract
@@ -0,0 +1,106 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license block
@@ -0,0 +1,21 @@ | |||
<?php | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license block
Thank you, Loïc! 🎉 |
When using
bin/console make:entity
command, a repository is automatically generated extending ServiceEntityRepository.I propose with this PR a simple way to keep using this generated repository with two simple changes: