Skip to content

Commit

Permalink
[Docs] Disable processing data
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Aug 30, 2024
1 parent 32fdd37 commit 5d846d7
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions docs/processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
Processors process data: send an email, persist to storage, add to queue etc.

<!-- TOC -->
* [Default processors](#default-processors)
* [Custom processors](#custom-processors)
* [Sending an email after persisting data](#example-1-sending-an-email-after-persisting-data)
* [Use a custom delete processor](#example-2-use-a-custom-delete-processor)
* [Processors](#processors)
* [Default processors](#default-processors)
* [Custom processors](#custom-processors)
* [Example #1: Sending an email after persisting data](#example-1-sending-an-email-after-persisting-data)
* [Example #2: Use a custom delete processor](#example-2-use-a-custom-delete-processor)
* [Disable processing data](#disable-processing-data)
<!-- TOC -->

## Default processors
Expand Down Expand Up @@ -152,6 +154,37 @@ use Sylius\Resource\Model\ResourceInterface;
final class BoardGameResource implements ResourceInterface
```

## Disable processing data

In some cases, you may want not to write data.

For example, you can implement a preview for the updated data without saving them into your storage.

```php
// src/BoardGameBlog/Infrastructure/Sylius/Resource/BoardGameResource.php

namespace App\BoardGameBlog\Infrastructure\Sylius\Resource;

use App\BoardGameBlog\Infrastructure\Sylius\State\Http\Provider\BoardGameItemProvider;
use Sylius\Resource\Metadata\AsResource;
use Sylius\Resource\Metadata\Delete;
use Sylius\Resource\Model\ResourceInterface;

#[AsResource(
alias: 'app.board_game',
section: 'admin',
formType: BoardGameType::class,
templatesDir: 'crud',
routePrefix: '/admin',
)]
#[Update(
shortName: 'update_preview',
provider: BoardGameItemProvider::class,
write: false,
)]
final class BoardGameResource implements ResourceInterface
```

**[Go back to the documentation's index](index.md)**

**[> Next chapter: Responders](responders.md)**

0 comments on commit 5d846d7

Please sign in to comment.