Posted on 6/7/06 by Felix Geisendörfer
Gopher just asked me weather it was possible in CakePHP to see if an action was invoked by the dispatcher or called by $this->action();. So since I think this is one of these things that could be useful for others as well, here is my solution:
All you need to do is to check whether $this->action and the name of the function that is currently beeing executed match. This can be done like this:
So for example you could use it like this:
$post3 = $this->view(3);
$post = $this->Post->find(array('id' => $id));
if ($this->action != __FUNCTION__)
Ok, this is a pretty useless example I have to admit, but I'm sure there are more interesting ways to utilize this ; ).
--Felix Geisendörfer aka the_undefined
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.