O'Reilly logo

Extending Symfony2 Web Application Framework by Sébastien Armand

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Versioning

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required