rcrowe/TwigBridge

TwigBridge doesn't call __get on unknown properties: it seems to read from a serialized version of object

mpfrenette opened this issue · 2 comments

My model has dynamic properties which are accessible via the __get function.

if I use:

{{obj.__get('property')}}

It works in my TWIG template, but if I do:

{{obj.property}}

It doesn't work, and yet, in php, if I do obj.property, it works...

My impression, is that instead of using the model itself, it works on a serialization of the model.

In that case, I see 2 possible solutions to my problem (but I don't know yet how to implement either), but perhaps there are more:

1 ) Modify the serialization
2 ) Modify Twig to use the object instead of a serialization of it.

I had an hint of a solution... simply override the toArray() function, which would allow to add the dynamic values... EXCEPT that it's not called when initializing Twig, so that doesn't work.

Problem solved on my side! I simply use getAttribute instead of __get...

I am closing this issue