craftcms / webhooks

Plugin for integrating Craft with Zapier and IFTTT.
https://plugins.craftcms.com/webhooks
MIT License
84 stars 12 forks source link

Event inside payload only listing public property values #2

Closed gustavs-gutmanis closed 5 years ago

gustavs-gutmanis commented 5 years ago

As it is currently, only the public properties of the Event are added to the webhook's payload.

What if we have private properties that are only exposed via getters and have setters that define how class properties should be altered? Not only is having properties public not a good practice, some events have special logic taking place which updates its properties in a given manner and thus they cannot be exposed. Otherwise, third party plugins capturing that event might corrupt the data and cause unexpected side-effects.

Would you consider adding, for instance, a check that determines if the Event implements \JsonSerializable and then use its ::jsonSerialize() instead of looking through exposed public properties? Or perhaps check for the presence of getter methods akin to symfony/property-access?