Events
Last updated
Was this helpful?
Last updated
Was this helpful?
The events that are designed for the entities have a general naming convention: sylius.entity_name.event_name
.
The examples of such events are: sylius.product.pre_update
, sylius.shop_user.post_create
, sylius.taxon.pre_create
.
All Sylius bundles are using , which has some built-in events.
sylius.<resource>.pre_create
Before persist
sylius.<resource>.post_create
After flush
sylius.<resource>.pre_update
Before flush
sylius.<resource>.post_update
After flush
sylius.<resource>.pre_delete
Before remove
sylius.<resource>.post_delete
After flush
sylius.<resource>.initialize_create
Before creating view
sylius.<resource>.initialize_update
Before creating view
As you should already know, every resource controller is represented by the sylius.controller.<resource_name>
service. Several useful events are dispatched during the execution of every default action of this controller. When creating a new resource via the createAction
method, 2 events occur.
First, before the persist()
is called on the resource, the sylius.<resource_name>.pre_create
event is dispatched.
After the data storage is updated, sylius.<resource_name>.post_create
is triggered.
The same set of events is available for the update
and delete
operations. All the dispatches are using the GenericEvent
class and return the resource object by the getSubject
method.
To dispatch checkout steps the event names are overloaded. See _sylius.event
in src/Sylius/Bundle/ShopBundle/Resources/config/routing/checkout.yml
sylius.order.initialize_address
Before creating address view
sylius.order.initialize_select_shipping
Before creating shipping view
sylius.order.initialize_payment
Before creating payment view
sylius.order.initialize_complete
Before creating complete view
Even though Sylius has events as entry points to each resource only some of these points are already used in our use cases.
The events already used in Sylius are described in the Book alongside the concepts they concern.