Create doctrine repository

From PrestaShop/PrestaShop · View interactive version

Create doctrine repository is an AI agent skill from the GitHub repository PrestaShop/PrestaShop. Create the repository in the Adapter layer. This is the ONLY class that touches the database — all handlers delegate to it. Covers multistore patterns with ShopConstraint when the entity requires it. Trigger: "create repository for {Domain}".

How to use this skill

Skill file

create-doctrine-repository

See CQRS/CONTEXT.md for conventions (stateless, no Context dependency, multistore tier model, typed exceptions).

1. Choose the base class

Create src/Adapter/{Domain}/{Domain}Repository.php. Choose the base class based on the multistore tier table in CONTEXT.md.

2. Core methods

Implement these methods (adapt naming to your domain):

Reference: src/Adapter/Tax/CommandHandler/ uses a simple repository pattern, src/Adapter/Carrier/CommandHandler/ uses AbstractMultiShopObjectModelRepository

3. Multistore pattern (when using AbstractMultiShopObjectModelRepository)

4. Sub-resource methods (if applicable)

For entities with has-many sub-resources, two strategies:

Atomic replace (simpler)

Incremental update (cleaner)

Rules

Conventions (stateless, no Context, typed exceptions) are in CQRS/CONTEXT.md. Skill-specific reminders:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.