This commit is contained in:
2026-06-10 18:22:27 +02:00
parent 7f31b63aaa
commit 83b475987c
50 changed files with 2550 additions and 11 deletions
@@ -0,0 +1,22 @@
---
globs: '["src/**/*Repository.php"]'
description: Ensures minimal boilerplate by avoiding unnecessary custom
Repository classes for standard CRUD operations, while still allowing them for
complex queries.
alwaysApply: true
---
In Symfony and Doctrine based applications, avoid creating custom Repository classes for simple CRUD or standard query operations (e.g., findOneBy, findBy). Instead, use Doctrine's native EntityRepository directly via $entityManager->getRepository(Entity::class) within the Provider or Processor implementations.
Only create a custom repository when:
1. Complex queries involving multiple joins, subselects, or specialized search logic are required.
2. Query logic is reused across multiple Providers/Processors and warrants encapsulation for DRY compliance.
When no custom repository is needed, Inject EntityManagerInterface directly into the Provider or Processor and fetch the repository inline as shown below:
```php
$repository = $this->entityManager->getRepository(EntityClass::class);
$result = $repository->findOneBy(['id' => $id]);
```
Do not create an empty or wrapper Repository class that only delegates to Doctrine's native methods.