Basic operations
In the previous chapter, we have created the Sylius resource. Now, we need to create the basic operations. To achieve that, we reuse commands & queries we already have in the Application folder to create providers & processors.
src
└── BookStore
├── Application
│ ├── Command
│ │ ├── CreateBookCommand.php
│ │ ├── UpdateBookCommand.php
│ │ └── DeleteBookCommand.php
│ └── Query
│ └── FindBookQuery.php
├── Domain
└── Infrastructure
└── Sylius
└── State
├── Provider
│ └── BookItemProvider.php
└── Processor
├── CreateBookProcessor.php
├── UpdateBookProcessor.php
└── DeleteBookProcessor.phpBook creation

In the Application folder, we already have this CreateBookCommand:
The idea is to reuse this command to create the book in the storage for your "create" operation.
Create the CreateBookProcessor
First, we need to add the CreateBookProcessor in which we're going to call our CreateBookCommand.
Adding the processor on the Book Resource
Then, we add the Create operation on our BookResource.
Book edition

Now, we want to be able to edit an existing book. In the Application folder, we already have this UpdateBookCommand:
In the same folder, we also have this existing FindBookQuery:
The idea is to reuse these query and command to update the book in the storage for your "update" operation.
Create the BookItemProvider
First, we need to create the BookItemProvider in order to fetch the right book.
Create the UpdateBookProcessor
We also need to create the UpdateBookProcessor where we're going to call our UpdateBookCommand.
Adding the provider & processor on the Book Resource
Now, we add the "update" operation on the BookResource.
Book removal

Now that we can update an existing book, we also want to be able to delete it. In the Application folder, we already have this DeleteBookCommand:
Create the DeleteBookProcessor
We need to create the DeleteBookProcessor.
Adding the processor on the Book Resource
And then we create the "delete" operation on the BookResource.
Last updated