modmore / ClientConfig

ClientConfig is a MODX Revolution Extra to allow clients to maintain settings in a user friendly way.
https://docs.modmore.com/en/Open_Source/ClientConfig/index.html
MIT License
28 stars 27 forks source link

Feature-Request: Get current working context inside invoke event `ClientConfig_ConfigChange` #206

Open sebastian-marinescu opened 1 year ago

sebastian-marinescu commented 1 year ago

Summary

When developing a plugin that listens to ClientConfig_ConfigChange, inside a multi-context-aware setup, there is no way of knowing which context just got changed/updated.

Step to reproduce

Inside a plugin try to get the settings to the currently changed context:

// This always returns `mgr`, which sort of is correct:
$contextKey = $modx->context instanceof modContext || $modx->context instanceof \MODX\Revolution\modContext ? $modx->context->get('key') : 'web';
$settings = $clientConfig->getSettings($contextKey);

Observed/Expected behavior

There is currently no way to know which context got changed. When the event is invoked, it would be beneficial to also send the context-key of the currently changed context.

Environment

ClientConfig 2.3.3-pl MODX Revolution 2.8.5-pl