Class NEnvironment (namespace Nette)


Nette environment and configuration.


Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Environment.php (line 29)
Public Method Summary
NEnvironment
Static class - cannot be instantiated.
static string
expand (string $var)
Returns expanded variable.
static NApplication
static NCache
getCache ([string $namespace = ''])
static mixed
getConfig ([string $key = NULL], [mixed $default = NULL])
Returns the global configuration.
static NConfigurator
Gets "class behind NEnvironment" configurator.
static NHttpRequest
static NHttpResponse
static bool
getMode (string $mode)
Returns the mode.
static string
getName ()
Returns the current environment name.
static object
getService (string $name, [$options = NULL])
Gets the service object of the specified type.
static IServiceLocator
Get initial instance of service locator.
static NSession
getSession ([string $namespace = NULL])
Returns instance of session or session namespace.
static NUser
getUser ()
static mixed
getVariable (string $name, [mixed $default = NULL])
Returns the value of an environment variable or $default if there is no element set.
static array
Returns the all environment variables.
static bool
Detects console (non-HTTP) mode.
static void
static bool
Determines whether a server is running in production mode.
static ArrayObject
loadConfig ([string|NConfig $file = NULL])
Loads global configuration from file and process it.
static void
setConfigurator (NConfigurator $configurator)
Sets "class behind NEnvironment" configurator.
static void
setMode (string $mode, [bool $value = TRUE])
Sets the mode.
static void
setName (string $name)
Sets the current environment name.
static void
setServiceAlias (string $service, string $alias)
Adds new NEnvironment::get<Service>() method.
static void
setVariable (string $name, mixed $value, [bool $expand = TRUE])
Sets the environment variable.
static object service
__callStatic (string $name, array $args)
Calling to undefined static method.
Constant Summary
string CONSOLE 'console'

line 34

environment name
string DEBUG 'debug'

line 39

mode name
string DEVELOPMENT 'development'

line 32

environment name
string LAB 'lab'

line 35

environment name
string PERFORMANCE 'performance'

line 40

mode name
string PRODUCTION 'production'

line 33

environment name

Method Details

line 81

__construct

public NEnvironment __construct ()

Static class - cannot be instantiated.

Output
NEnvironment  

line 291

expand

public static string expand (string $var)

Returns expanded variable.

Input
string $var
Output
string  
Throws
throws InvalidStateException

line 422

getApplication

public static NApplication getApplication ()

Output
NApplication  

line 447

getCache

public static NCache getCache ([string $namespace = ''])

Input
string $namespace
Output
NCache  

line 492

getConfig

public static mixed getConfig ([string $key = NULL], [mixed $default = NULL])

Returns the global configuration.

Input
string $key key
mixed $default default value
Output
mixed  

line 104

getConfigurator

public static NConfigurator getConfigurator ()

Gets "class behind NEnvironment" configurator.

Output
NConfigurator  

line 402

getHttpRequest

public static NHttpRequest getHttpRequest ()

Output
NHttpRequest  

line 412

getHttpResponse

public static NHttpResponse getHttpResponse ()

Output
NHttpResponse  

line 172

getMode

public static bool getMode (string $mode)

Returns the mode.

Input
string $mode mode identifier
Output
bool  

line 140

getName

public static string getName ()

Returns the current environment name.

Output
string  

line 362

getService

public static object getService (string $name, [$options = NULL])

Gets the service object of the specified type.

Input
string $name service name
$options options in case service is not singleton
Output
object  

line 346

getServiceLocator

public static IServiceLocator getServiceLocator ()

Get initial instance of service locator.

Output
IServiceLocator  

line 462

getSession

public static NSession getSession ([string $namespace = NULL])

Returns instance of session or session namespace.

Input
string $namespace
Output
NSession  

line 432

getUser

public static NUser getUser ()

Output
NUser  

line 244

getVariable

public static mixed getVariable (string $name, [mixed $default = NULL])

Returns the value of an environment variable or $default if there is no element set.

Input
string $name
mixed $default default value to use if key not found
Output
mixed  
Throws
throws InvalidStateException

line 274

getVariables

public static array getVariables ()

Returns the all environment variables.

Output
array  

line 188

isConsole

public static bool isConsole ()

Detects console (non-HTTP) mode.

Output
bool  

line 209

isDebugging

public static void isDebugging ()

Output
void  
Tags
Deprecated

line 199

isProduction

public static bool isProduction ()

Determines whether a server is running in production mode.

Output
bool  

line 479

loadConfig

public static ArrayObject loadConfig ([string|NConfig $file = NULL])

Loads global configuration from file and process it.

Input
string|NConfig $file file name or NConfig object
Output
ArrayObject  

line 93

setConfigurator

public static void setConfigurator (NConfigurator $configurator)

Sets "class behind NEnvironment" configurator.

Input
NConfigurator $configurator
Output
void  

line 159

setMode

public static void setMode (string $mode, [bool $value = TRUE])

Sets the mode.

Input
string $mode mode identifier
bool $value set or unser
Output
void  

line 124

setName

public static void setName (string $name)

Sets the current environment name.

Input
string $name
Output
void  
Throws
throws InvalidStateException

line 375

setServiceAlias

public static void setServiceAlias (string $service, string $alias)

Adds new NEnvironment::get<Service>() method.

Input
string $service service name
string $alias alias name
Output
void  

line 227

setVariable

public static void setVariable (string $name, mixed $value, [bool $expand = TRUE])

Sets the environment variable.

Input
string $name
mixed $value
bool $expand
Output
void  

line 388

__callStatic

public static object service __callStatic (string $name, array $args)

Calling to undefined static method.

Input
string $name method name
array $args arguments
Output
object service