A common issue when a lot of users have access to modifying the same resources is to make sure that they are not overwriting each other's changes. One technique to prevent this from happening is to version the resources. In Doctrine, we can set a version number to any entity when we first persist it, and then increment it whenever there is a request to change the information.
This will allow us to check if the version number of the incoming request is at least equal to the current one in the database. If not, refuse the change and force the user to refresh before updating the content.
Doctrine also uses events that we can listen to. These are as follows:
prePersist: This event is triggered before the entity is persisted to the database ...