Skip to content

Commit 2ce6386

Browse files
authored
minor #914 [Docs] Disable processing data (loic425)
This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | --------------- | ----- | Bug fix? | no (but missing documentation) | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT Based on #913 Commits ------- 6cf9f0d [Docs] Disable processing data
2 parents db225ad + 6cf9f0d commit 2ce6386

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

docs/processors.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Processors process data: send an email, persist to storage, add to queue etc.
55
<!-- TOC -->
66
* [Default processors](#default-processors)
77
* [Custom processors](#custom-processors)
8-
* [Sending an email after persisting data](#example-1-sending-an-email-after-persisting-data)
9-
* [Use a custom delete processor](#example-2-use-a-custom-delete-processor)
8+
* [Example #1: Sending an email after persisting data](#example-1-sending-an-email-after-persisting-data)
9+
* [Example #2: Use a custom delete processor](#example-2-use-a-custom-delete-processor)
10+
* [Disable processing data](#disable-processing-data)
1011
<!-- TOC -->
1112

1213
## Default processors
@@ -130,6 +131,38 @@ final class BoardGameResource implements ResourceInterface
130131
Note that in a delete operation, you can disable providing data.
131132
See [Disable providing data](providers.md#disable-providing-data) chapter.
132133

134+
## Disable processing data
135+
136+
In some cases, you may want not to write data.
137+
138+
For example, you can implement a preview for the updated data without saving them into your storage.
139+
140+
```php
141+
// src/BoardGameBlog/Infrastructure/Sylius/Resource/BoardGameResource.php
142+
143+
namespace App\BoardGameBlog\Infrastructure\Sylius\Resource;
144+
145+
use App\BoardGameBlog\Infrastructure\Sylius\State\Http\Provider\BoardGameItemProvider;
146+
use App\BoardGameBlog\Infrastructure\Symfony\Form\Type\BoardGameType;
147+
use Sylius\Resource\Metadata\AsResource;
148+
use Sylius\Resource\Metadata\Update;
149+
use Sylius\Resource\Model\ResourceInterface;
150+
151+
#[AsResource(
152+
alias: 'app.board_game',
153+
section: 'admin',
154+
formType: BoardGameType::class,
155+
templatesDir: 'crud',
156+
routePrefix: '/admin',
157+
)]
158+
#[Update(
159+
shortName: 'update_preview',
160+
provider: BoardGameItemProvider::class,
161+
write: false,
162+
)]
163+
final class BoardGameResource implements ResourceInterface
164+
```
165+
133166
**[Go back to the documentation's index](index.md)**
134167

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

0 commit comments

Comments
 (0)