Context
Context includes methods used to handle information about the current query: type, parameters and their values .
When initialized, creates context - a HttpContext object that stores information about the query as a container: query parameters, server environment, bitrix environment (language, site id), response to query. This means, that it is a modifiable portion that depends on the current hit.
Queries the following namespace:
To get the context of the current hit, execute the following:
$context = Application::getInstance()->getContext(); // Or more brief form: $context = Context::getCurrent();
Examples:
$request = $context->getRequest(); // Request object $server = $context->getServer(); // Server object $siteId = $context->getSite(); // Current site ID ("s1") $langId = $context->getLanguage(); // Current language ID ("en")
Method | Description | Available from version |
---|---|---|
Constructor | Creates a new context instance | |
getApplication | Returns a back link for the application | |
getCulture | Returns regional and cultural settings for a context. | |
getCurrent | Returns the current instance of context. | |
getLanguage | Returns the current language layout. | |
getRequest | Returns the requested context object. | |
getResponse | Returns an object of context response. | |
getServer | Returns server object of context. | |
getSite | Returns the current site. | |
initialize | Initializes context by query or object response. | |
setCulture | Sets regional and cultural settings for context. | |
setLanguage | Set a context language. | |
setSite | Sets site for context. |
Find additional details about context here.
© «Bitrix24», 2001-2024