How do I programmatically check if a context is active?
I figured it out: The Context module defines a service for getting the ContextManager object, which has getActiveContexts(). You can obtain it using the following code.

$activeContexts = \Drupal::service('context.manager')-&gt;getActiveContexts();


I need to read Service Container.