Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnContextInit System Event #16552

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

christianseel
Copy link
Contributor

What does it do?

Adds a new core system event OnContextInit, invoked after each successful context initialization (includes those when switchContext() is called.

Why is it needed?

We are having a project where we need to populate some data, that is context specific. To do so, we added a plugin to run each time a (new) context is initialized. Previously this was only possible via the event OnMODXInit, however this is only fired after the very first initialization of MODX. If you programmatically call switchContext() to init another context, there was no existing event to hook into.

How to test

Add a plugin with a log line and activate the new system event OnContextInit. Log gets printed during modx initialization and when you programmatically call switchContext() with another context key.

Related issue(s)/PR(s)

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 21.59%. Comparing base (1b01af2) to head (0bfdc96).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.x   #16552      +/-   ##
============================================
+ Coverage     21.57%   21.59%   +0.01%     
  Complexity    10577    10577              
============================================
  Files           561      561              
  Lines         31975    31982       +7     
============================================
+ Hits           6898     6905       +7     
  Misses        25077    25077              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Mark-H Mark-H added this to the v3.1.0 milestone Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants