Actually it would not be cleaner, as you are creating a hidden dependency. Always pass the parameters a function needs to work with. There are ways of doing this, of course, (hint a global variable through Configure or any other static class)
On Monday, December 15, 2014 1:05:48 PM UTC+1, frocco wrote:
-- On Monday, December 15, 2014 1:05:48 PM UTC+1, frocco wrote:
I have a product model and need a function in the entity to return certain pricing info based on who is logged in.I am getting around this by setting a state variable in the controller beforeFilter and passing that to the function from the view.It would be cleaner if I could do this in the model.I did this using Yii and django, but would like to do this using cake as it is much farther along in my port.ThanksFrank
On Monday, December 15, 2014 3:37:13 AM UTC-5, José Lorenzo wrote:You can pass it in an entity property, what are you trying to do?
On Sunday, December 14, 2014 7:53:48 PM UTC+1, frocco wrote:Hello,Having a hard time getting this to work.I want to access the logged in user's model from another model (product)Thanks
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:
Post a Comment