From 45f7fa17c373eeb4d9c808f45f68cc85efeb7bd1 Mon Sep 17 00:00:00 2001 From: tristan Date: Fri, 29 May 2026 15:14:16 +0200 Subject: [PATCH] =?UTF-8?q?docs(arch)=20:=20regle=20ABSOLUE=20n=C2=B013=20?= =?UTF-8?q?'pagination=20obligatoire'=20+=20standard=20backend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/rules/backend.md | 58 ++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 2 ++ 2 files changed, 60 insertions(+) diff --git a/.claude/rules/backend.md b/.claude/rules/backend.md index e21a688..4079df4 100644 --- a/.claude/rules/backend.md +++ b/.claude/rules/backend.md @@ -13,6 +13,64 @@ - Le login `/login_check` est **hors** prefix `/api` (nginx reecrit `REQUEST_URI` vers `/login_check`) - **Exception** : si tu dois creer un controller custom sous `/api/`, mettre `priority: 1` sur `#[Route]` pour eviter le conflit avec API Platform `{id}` +## Pagination (obligatoire) + +**Regle** : toute collection API DOIT etre paginee. Aucun retour de collection complete cote serveur. + +### Standard global + +Pose dans `config/packages/api_platform.yaml` (section `defaults:`) et heritee par toutes les ressources : + +| Cle | Valeur | Effet | +|---|---|---| +| `pagination_enabled` | `true` | Pagination Hydra active par defaut. | +| `pagination_items_per_page` | `10` | Taille de page par defaut, aligne sur l'UI `MalioDataTable`. | +| `pagination_maximum_items_per_page` | `50` | Borne dure : `?itemsPerPage=999` โ†’ ramene a 50. Anti deep-fetch. | +| `pagination_client_items_per_page` | `true` | Le client peut envoyer `?itemsPerPage=25` (bornee par le max). | +| `pagination_client_enabled` | `true` | Le client peut envoyer `?pagination=false` pour TOUT recuperer (echappatoire selects). | + +### Override par ressource (rare) + +Si une ressource a besoin d'un autre defaut (ex: payload lourd), utiliser les attributs sur l'operation. **JAMAIS `paginationEnabled: false`** sans whitelist explicite dans `tests/Architecture/CollectionsArePaginatedTest::EXCLUDED`. + +```php +new GetCollection( + paginationItemsPerPage: 5, // override taille par defaut + paginationMaximumItemsPerPage: 20, // override borne max +) +``` + +### Selects et autocompletions + +Pour alimenter un `