Tuesday, September 23, 2014

Re: Cake3 - Clean way to use session in models


Another similar idea using a Component instead of a trait:

https://github.com/alaxos/cakephp3-libs/blob/master/src/Controller/Component/UserLinkComponent.php
https://github.com/alaxos/cakephp3-libs/blob/master/src/Model/Behavior/UserLinkBehavior.php

Nico


On Tuesday, September 23, 2014 2:03:06 PM UTC+2, euromark wrote:
I would say: Pass in the data from the controller.

Also - this should give you an answer:

mark


Am Dienstag, 23. September 2014 10:02:27 UTC+2 schrieb bato:
Hi,

I would know if there is a way to access to session user in Models. I have a table with user_created and user_modified fields.
Saving Table user_created is only filled if Entity is new instead user_modified is always filled.
 
I can populate user_created and user_modified in controller but I'd like to set those fields in Table beforeSave to avoid to always remember to do that in controller each time I save that Table. 
Indeed this Table is saved in many controllers and other Tables can save it.

Thanks
Alberto

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: