Monday, September 28, 2009

Re: Controller::setAction heads-up

Ok tnx now I understand the problem, though I still can't wrap my head around the core issue.

Is it that call_user_func_array() can never call private methods ? I found some comments here and there on the web stating that the new Reflection API will solve this, but nothing concrete on calling private methods ...

As far as I can tell it can't be an OO issue, since TransactionsController will inherit the setAction() method from Controller ... therefore calling setAction() on an instance of TransactionsController should be allowed to access the private method error() that is defined in the same TransactionsController class.

I love a good quiz now and then :)

On Mon, Sep 28, 2009 at 5:35 PM, brian <bally.zijn@gmail.com> wrote:

On Mon, Sep 28, 2009 at 11:20 AM, Bert Van den Brande <cyruzb@gmail.com> wrote:
> I don't entirely understand why moving the target action from private to
> protected or public results in the $viewVars being set or not set ?

The first line in setAction() changes the controller's $action:

$this->action = $action;

Then, the last line of the method fails on call_user_func_array()
because the given action is private:

Warning (2): call_user_func_array()
[http://php.net/function.call-user-func-array]: First argument is
expected to be a valid callback, 'TransactionsController::error' was
given [CORE_1.2.5/cake/libs/controller/controller.php, line 697]

However, it's not a fatal error and the controller's $action has
already been changed, so it's the view for this that is used in
render() even though the action is never called.

Anyway, it's not a Cake bug. I just wanted to post this for anyone
else who might run into it.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: