‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Core\ApplicationContext Class Reference

Public Member Functions

 __construct ($contextString)
 
string __toString ()
 
bool isDevelopment ()
 
bool isProduction ()
 
bool isTesting ()
 
TYPO3 CMS Core Core ApplicationContext null getParent ()
 

Protected Attributes

string $contextString
 
string $rootContextString
 
TYPO3 CMS Core Core ApplicationContext null $parentContext
 

Detailed Description

The TYPO3 Context object.

A TYPO3 Application context is something like "Production", "Development", "Production/StagingSystem", and is set using the TYPO3_CONTEXT environment variable.

A context can contain arbitrary sub-contexts, which are delimited with slash ("Production/StagingSystem", "Production/Staging/Server1"). The top-level contexts, however, must be one of "Testing", "Development" and "Production".

Mainly, you will use $context->isProduction(), $context->isTesting() and $context->isDevelopment() inside your custom code.

ATTENTION: The Testing context is only used internally when executing TYPO3 Core tests. It must not be used otherwise.

This class is derived from the TYPO3 Flow framework. Credits go to the respective authors.

Definition at line 38 of file ApplicationContext.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Core\ApplicationContext::__construct (   $contextString)

Initialize the context object.

Parameters
string$contextString
Exceptions
Exception‪if the parent context is none of "Development", "Production" or "Testing"

Definition at line 64 of file ApplicationContext.php.

References TYPO3\CMS\Core\Core\ApplicationContext\$contextString.

Member Function Documentation

◆ __toString()

string TYPO3\CMS\Core\Core\ApplicationContext::__toString ( )

Returns the full context string, for example "Development", or "Production/LiveSystem"

Returns
‪string

Definition at line 88 of file ApplicationContext.php.

References TYPO3\CMS\Core\Core\ApplicationContext\$contextString.

◆ getParent()

TYPO3 CMS Core Core ApplicationContext null TYPO3\CMS\Core\Core\ApplicationContext::getParent ( )

Returns the parent context object, if any

Returns
‪\TYPO3\CMS\Core\Core\ApplicationContext|null the parent context or NULL, if there is none

Definition at line 128 of file ApplicationContext.php.

References TYPO3\CMS\Core\Core\ApplicationContext\$parentContext.

◆ isDevelopment()

bool TYPO3\CMS\Core\Core\ApplicationContext::isDevelopment ( )

Returns TRUE if this context is the Development context or a sub-context of it

Returns
‪bool

Definition at line 98 of file ApplicationContext.php.

◆ isProduction()

bool TYPO3\CMS\Core\Core\ApplicationContext::isProduction ( )

Returns TRUE if this context is the Production context or a sub-context of it

Returns
‪bool

Definition at line 108 of file ApplicationContext.php.

◆ isTesting()

bool TYPO3\CMS\Core\Core\ApplicationContext::isTesting ( )

Returns TRUE if this context is the Testing context or a sub-context of it

Returns
‪bool

Definition at line 118 of file ApplicationContext.php.

Member Data Documentation

◆ $contextString

string TYPO3\CMS\Core\Core\ApplicationContext::$contextString
protected

The (internal) context string; could be something like "Development" or "Development/MyLocalMacBook"

Definition at line 44 of file ApplicationContext.php.

Referenced by TYPO3\CMS\Core\Core\ApplicationContext\__construct(), and TYPO3\CMS\Core\Core\ApplicationContext\__toString().

◆ $parentContext

TYPO3 CMS Core Core ApplicationContext null TYPO3\CMS\Core\Core\ApplicationContext::$parentContext
protected

The parent context, or NULL if there is no parent context

Definition at line 56 of file ApplicationContext.php.

Referenced by TYPO3\CMS\Core\Core\ApplicationContext\getParent().

◆ $rootContextString

string TYPO3\CMS\Core\Core\ApplicationContext::$rootContextString
protected

The root context; must be one of "Development", "Testing" or "Production"

Definition at line 50 of file ApplicationContext.php.