I'm developing a CakePHP 3 application.
Now, i need to encrypt some data with SHA1 before the save of the entity.
I tried the beforeSave() callback in Table Object, like in CakePHP 2.x, but it doesn't work.
So, i discovered that type of change (update data on beforeSave/beforeUpdate) in current version, needs to be adapted to accessors & mutators, like the docs says (http://book.cakephp.org/3.0/en/orm/entities.html#accessors-mutators).
Documentation even has a note about check if an entity field was modified (http://book.cakephp.org/3.0/en/orm/entities.html#checking-if-an-entity-has-been-modified) but i dont understand how to use this.
I need some simple logic, just like an authentication system.
Before Save, in User Model, the field responsible_card_password must be hashed with SHA1 if this is filled. If isnt filled, the field stays the same.
Currently, with the acessors and mutators method, if i put the field on form blank, the entity save this field blank.
How i can solve this? Very thanks CakePHP developers on the world! :-D