Domanda

So I'm confused about Doctrine 2's lifecycle events. I have a subscriber event class that implements prePersit, preUpdate, postUpdate, and postLoad. Basically what I'm trying to do is to encrypt an entity's particular value on "prePersist" and "preUpdate" (when updating a value), and decrypt the value on "postLoad".

The decryption is working perfectly. However, I'm currently having two problems with these lifecycle events:

  1. when "preUpdate" is triggered, it encrypts the value correctly (looking at my debugger) but once it gets committed to the database, I can see the that value is in clear text. What's the deal here?
  2. I have also implemented the "postUpdate" event, which I was thinking that it would be triggered after the update is committed to the database, which would give me chance to decrypt the value for viewing on the UI, but following the debugger this is not case. The preUpdate is triggered first when doing an update, then followed by postUpdate, and finally this changes are committed to the database. Which event life cycle should I be using for this case?
È stato utile?

Soluzione

The signature on preUpdate must be on type PreUpdateEventArgs. This link has more info on to get it working.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top