Skip to content
Back to skills

Create Controller Listing

ASecurity

Create the listing page actions in the admin controller: index (grid with filters), delete, toggle status, and any bulk actions the entity requires. Trigger: "create listing for {Domain}", "create index action for {Domain}".

  • 6 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 29, 2026
ai-agentsphpsecurity

Security analysis

A100/100

Scanned May 29, 2026

npx -y skills add jeffsenso/prestashop-skills --skill create-controller-listing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Create Controller Listing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Create Controller Listing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jeffsenso-create-controller-listing/badge)](https://www.skillsdirectory.com/skills/jeffsenso-create-controller-listing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: create-controller-listing
description: >
  Create the listing page actions in the admin controller: index (grid with filters),
  delete, toggle status, and any bulk actions the entity requires. Trigger:
  "create listing for {Domain}", "create index action for {Domain}".
needs: [create-cqrs-commands, create-grid]
produces: "indexAction, deleteAction, toggleStatusAction, bulk action methods in {Domain}Controller.php"
---

# create-controller-listing

Read `@.ai/Component/Controller/CONTEXT.md` for controller conventions (base class, DI, security attributes, error mapping).
Read `@.ai/Component/Grid/CONTEXT.md` for grid patterns (definition factory, query builder, filters).

## 1. Index action

```php
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
public function indexAction({Domain}Filters $filters): Response
```

- Use the `{Domain}Filters` class as action argument — automatically resolved by the argument resolver
- Build grid via the grid factory service, present it, render the index template
- No manual `SearchCriteria` construction needed

**Reference:** `TaxController::indexAction()`, `ManufacturerController::indexAction()`

## 2. Search and reset

- **Search/filter:** `CommonController::searchGridAction` saves and applies grid filters, then redirects back to the domain's index action. A domain-specific route must be defined pointing to this generic controller action (see `create-admin-routing`)
- **Filter reset:** uses the generic route `admin_common_reset_search_by_filter_id` — no domain-specific route or controller code needed. Referenced from the `GridDefinition`

## 3. Delete action

```php
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))")]
public function deleteAction(int ${domain}Id): RedirectResponse
```

- Dispatch `Delete{Domain}Command` via command bus
- Catch `{Domain}NotFoundException` and `CannotDelete{Domain}Exception`
- Flash appropriate message, redirect to index

## 4. Toggle status action

```php
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))")]
public function toggleStatusAction(int ${domain}Id): JsonResponse
```

- Dispatch `Toggle{Domain}StatusCommand` via command bus
- Return `JsonResponse` (AJAX grid toggle switch)

## 5. Bulk actions

Create one method per bulk action the grid defines — not all entities have the same set:

```php
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))")]
public function bulkDeleteAction(Request $request): RedirectResponse
```

Common pattern for all bulk actions:
- Extract selected IDs from request
- If empty selection, return early with info flash
- Dispatch the appropriate bulk command
- Catch bulk exceptions, flash with failed IDs (see [Controller/CONTEXT.md](../../CONTEXT.md))
- Redirect to index

## Rules

See [Controller/CONTEXT.md](../../CONTEXT.md) for all conventions (Filters argument, bulk exception handling, toggle JSON). Skill-specific reminder:

- Bulk actions match the grid definition — don't assume delete/enable/disable are always present

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.