# Create Doctrine Repository

> >

- **Type:** Skill
- **Install:** `agentstack add skill-jeffsenso-prestashop-skills-create-doctrine-repository`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [jeffsenso](https://agentstack.voostack.com/s/jeffsenso)
- **Installs:** 0
- **Category:** [Developer Tools](https://agentstack.voostack.com/c/developer-tools)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [jeffsenso](https://github.com/jeffsenso)
- **Source:** https://github.com/jeffsenso/prestashop-skills/tree/main/skills/prestashop-module-development/ps9-core-ai/Component/CQRS/skills/create-doctrine-repository

## Install

```sh
agentstack add skill-jeffsenso-prestashop-skills-create-doctrine-repository
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# create-doctrine-repository

See [CQRS/CONTEXT.md](../../CONTEXT.md#repository) 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):

- `get{Domain}({Domain}Id $id): {LegacyObjectModel}` — loads the ObjectModel, throws `{Domain}NotFoundException` if not found
- `create(...): {Domain}Id` — calls ObjectModel `save()` or `add()`, wraps in try/catch, returns new ID
- `update(...)` — calls ObjectModel `save()` or `update()`
- `delete({Domain}Id $id)` — deletes the entity, respects multistore if applicable

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

## 3. Multistore pattern (when using AbstractMultiShopObjectModelRepository)

- Receive `ShopConstraint` as a method parameter — never read it from Context
- Call `$shopIds = $this->getShopIdsByConstraint($shopConstraint)` at the start of every write
- Iterate `$shopIds` and apply the write for each shop context
- Modes: `ShopConstraint::allShops()`, `ShopConstraint::shop($shopId)`, `ShopConstraint::shopGroup($groupId)`
- Single-shop installs still go through this path (returns array with one ID)

## 4. Sub-resource methods (if applicable)

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

### Atomic replace (simpler)
- `set{SubResource}s({Domain}Id, array $items)` — delete all existing rows, insert new set
- Wrap in transaction — partial replace corrupts data

### Incremental update (cleaner)
- Compare existing rows with new collection, apply only changes
- Preferred when sub-resources have their own identity

## Rules

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

- Never use `Db::getInstance()` — use Doctrine DBAL or ObjectModel methods
- Never hard-code `Context::getContext()->shop->id` — receive shop as parameter

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [jeffsenso](https://github.com/jeffsenso)
- **Source:** [jeffsenso/prestashop-skills](https://github.com/jeffsenso/prestashop-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-jeffsenso-prestashop-skills-create-doctrine-repository
- Seller: https://agentstack.voostack.com/s/jeffsenso
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
