Skip to content
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

Arraization(?) is turning my Eloquent collections into strings (not arrays) #43

Open
martynbiz opened this issue Oct 14, 2016 · 1 comment

Comments

@martynbiz
Copy link

I'm passing in Eloquent Collections like so:

$engine->render('index/index', [
    'questions' => $questions,
);

If I var_export in the my controller class, the variable is set as an instance of Collection, but if I var_export within the template it's not an object, it's not an array even, but is a json_encoded string! I guess I could json_decode but is this the desired behaviour?

Also, how do I turn off Arraization for all templates? I might not wish to have this feature for now. Thanks

@gmazzap
Copy link
Contributor

gmazzap commented Oct 19, 2016

@martynbiz Arraization is needed for autoescape. You can turn it off by disabling autoescape.

Regarding Collection convert to JSON encoded string this is very weird, indeed.

Eloquent collections have a toArray method that is called by arraization routine to arrayize it.

Then, each element of the array is converted to array (if not scalar) using same method, which should never end up in a JSON encoded string...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants