[Neos] Computed properties & JSON

Dmitri Pisarev dimaip at gmail.com
Wed Apr 15 16:46:57 CEST 2015


Hey Tristan!
I like your idea of defining model in TS. But do not like the idea of
converting it into JSON in the same TS object!
IMHO the ViewHelper to convert to JSON would be the way to go. If not, try
EEL. JSON or HTML rendering are both parts of the view and should be kept
separate to have logic clean.

On Wed, 15 Apr 2015 at 12:00 Tristan Koch <typo3.org at tknetwork.de> wrote:

> Hi Dmitri!
>
> thank you for pointing my in the right direction. I believe I found an
> acceptable solution, but feel free to let me know if there is a better
> approach.
>
> The general idea is to have a central product TS object serving as the
> model. It is backed by a custom implementation that adds the property
> asJson to the context (which is a PHP array of properties meant be
> converted to JSON). This product model (or, to be precise instances of it)
> is used for both the HTML and JSON product item. One takeaway for me was
> the fact that properties of a TS object can be accessed from PHP via $this,
> another that (computed) properties can be added to the context using
> push/popContext (although this seems a little hacky considering the amount
> of code required).
>
> https://gist.github.com/trkoch/006cd219895d7a7cb8e1
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
>


More information about the Neos mailing list