Manual:ResourceLoaderContext.php

The   object. It encapsulates the request context for ResourceLoader requests. It can be thought of as the ResourceLoader equivalent of RequestContext, although the exact capabilities are different.

Developers commonly interact with the ResourceLoaderContext when writing callbacks for dynamically generated ResourceLoader files, or custom ResourceLoaderModule subclasses. Unlike RequestContext, ResourceLoaderContext cannot be obtained directly.

Like RequestContext, ResourceLoaderContext implements the MessageLocalizer interface and can be used for rendering i18n messages. Unlike normal requests, where rendering messages without a context is discouraged but possible, for ResourceLoader requests this is the only possible way to use i18n messages.

ResourceLoaderContext also provides access to the current language, language variant, language direction, and skin. It also has methods for getting the current user, but as most resources are cached in a way that allows them to be shared between users, this doesn't work as one might expect. Logic that depends on the current user should rather be handled via.