-
Notifications
You must be signed in to change notification settings - Fork 61
Invokable view variable shouldn't be invoked #85
Comments
Interestingly, that's a new feature, and it was done to allow defining helpers without requiring implementation of |
But how am I supposed to pass invokable objects then? In short to show that my situation is not special (at least IMHO): I want to pass a command-like object to the view (ReplaceTranslation) and I want to show a preview of that command output (via its invokable method) as well as its name. I have more commands. Workarounds I was thinking about:
All workarounds gave me a bad feeling. I don't know how a case like this should be handled (because of BC) but I somehow think that the current implementation is wrong because I have no chance to pass invokable objects - that are not meant to be invoked automatically - in a clean way. |
Am also having this problem. Had same ideas around workarounds, but all of these feel bad. I reversed engineered that some prior version ZF2 (beta most likely) had a |
Though it does have some nice properties ;)! In the end I chose to use the second approach, which was really not a big of a deal. |
This repository has been closed and moved to laminas/laminas-view; a new issue has been opened at laminas/laminas-view#18. |
Hi,
when passing an invokable object to the view and trying to access it, the object is being invoked automatically which may not be intended.
Expected output:
test
Actual output:
Argument 1 passed to class@anonymous::__invoke() must be of the type array, none given
The reason is here (
Zend/View/Variables.php
):The process of passing and accessing variables should not take care of the kind of the variables passed.
I really don't get the point of invoking them automatically. If someone needs automatic invocation we have view helpers. My suggestion is to remove the automatic invocation or if you can't let go, add an interface check.
The text was updated successfully, but these errors were encountered: