Answer the question
In order to leave comments, you need to log in
An event for an entity before it is updated?
The task is banal, before updating the entity, call the method.
At the initial save, the prePersist
event is triggered.
Subsequent persist do not channel, this is stated in the documentation
prePersist - The prePersist event occurs for a given entity before the respective EntityManager persist operation for that entity is executed. It should be noted that this event is only triggered on initial persist of an entity (ie it does not trigger on future updates).
app.listeners.category.save_image_in_listener:
class: App\Listeners\Category\SaveImageInListener
tags:
- name: 'doctrine.orm.entity_listener'
event: 'prePersist'
method: 'save'
entity: App\Entity\CategoryProduct
lazy: true
- name: 'doctrine.orm.entity_listener'
event: 'preUpdate' # не работает
method: 'save'
entity: App\Entity\CategoryProduct
lazy: true
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question