-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invokable view variable shouldn't be invoked #18
Comments
Interestingly, that's a new feature, and it was done to allow defining helpers without requiring implementation of Originally posted by @weierophinney at zendframework/zend-view#85 (comment) |
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. Originally posted by @antiphp at zendframework/zend-view#85 (comment) |
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 Originally posted by @roelvanduijnhoven at zendframework/zend-view#85 (comment) |
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. Originally posted by @roelvanduijnhoven at zendframework/zend-view#85 (comment) |
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.
Originally posted by @antiphp at zendframework/zend-view#85
The text was updated successfully, but these errors were encountered: