class ApplicationContext (View source)

The Flow Context object.

A Flow Application context is something like "Production", "Development", "Production/StagingSystem", and is set using the FLOW_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.

Properties

protected string $contextString

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

protected string $rootContextString

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

protected ApplicationContext $parentContext

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

protected string[] $hierarchy

Methods

__construct(string $contextString)

Initialize the context object.

string
__toString()

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

bool
isDevelopment()

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

bool
isProduction()

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

bool
isTesting()

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

getParent()

Returns the parent context object, if any

array
getHierarchy()

Returns the names of this context and all parents in ascending specificity

Details

__construct(string $contextString)

Initialize the context object.

Parameters

string $contextString

Exceptions

Exception

string __toString()

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

Return Value

string

bool isDevelopment()

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

Return Value

bool

bool isProduction()

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

Return Value

bool

bool isTesting()

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

Return Value

bool

ApplicationContext getParent()

Returns the parent context object, if any

Return Value

ApplicationContext

the parent context or NULL, if there is none

array getHierarchy()

Returns the names of this context and all parents in ascending specificity

Return Value

array

for example ['Production', 'Production/Staging', 'Production/Staging/Server1']