Processors

Processors process data: send an email, persist to storage, add to queue etc.

Default processors

When your resource is a Doctrine entity, there are default processors which are already configured to your operations.

As it uses the Doctrine repository configured on your resource, it will automatically flush data for you.

Operation
Processor

create

Sylius\Resource\Doctrine\Common\State\PersistProcessor

update

Sylius\Resource\Doctrine\Common\State\PersistProcessor

delete

Sylius\Resource\Doctrine\Common\State\RemoveProcessor

bulk delete

Sylius\Resource\Doctrine\Common\State\RemoveProcessor

Custom processors

Custom processors are useful to customize your logic to send an email, persist data to storage, add to queue and for an advanced usage such as an hexagonal architecture.

Example #1: Sending an email after persisting data

As an example, send an email after customer registration

Use this processor on your operation.

Example #2: Use a custom delete processor

As another example, let's configure a DeleteBoardGameProcessor on a BoardGameResource which is not a Doctrine entity.

Use this processor on your operation.

Note that in a delete operation, you can disable providing data. See Disable providing data chapter.

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.

Last updated