wintercms / wn-builder-plugin

GUI for building plugins in Winter CMS
MIT License
34 stars 12 forks source link

Allow $jsonable to be filled into model automatically #28

Closed bennothommo closed 2 years ago

bennothommo commented 2 years ago

Fixes https://github.com/wintercms/wn-builder-plugin/issues/21

This PR introduces simple PHP file manipulation through the PHP Parser library, and adds the ability for the Builder plugin to insert (or modify) a $jsonable property in a model, with the intention of populating this with column names for field types that need it (ie. repeater, multi-selection widgets, nested forms, etc.)

The pretty-printing in the PHP Parser library seems to be pretty good and not touching the code outside of any manipulated areas, but it's less good at making sure any new code matches the same coding style, so there is a trade-off here in that any inserted code might not look quite right in the context of the rest of the file, but the rest of the code around it should be left untouched. However, I think this will be fine for people using the Builder.