Class Environment (namespace Nette)


Nette environment and configuration.


Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Environment.php (line 30)
Public Method Summary
Environment
Static class - cannot be instantiated.
static string
expand (string $var)
Returns expanded variable.
static void
exportConstant (string|array $names)
Define one or more variables as constants.
static Application
static Cache
getCache ([string $namespace = ''])
static mixed
getConfig ([string $key = NULL], [mixed $default = NULL])
Returns the global configuration.
static Configurator
Gets "class behind Environment" configurator.
static IHttpRequest
static IHttpResponse
static bool
getMode (string $mode)
Returns the mode.
static string
getName ()
Returns the current environment name.
static mixed
getService (string $name, [bool $need = TRUE])
Gets the service object of the specified type.
static IServiceLocator
Get initial instance of service locator.
static Session|Nette\Web\Session
getSession ([string $namespace = NULL])
Returns instance of session or session namespace.
static IUser
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 bool
Detects console (non-HTTP) mode.
static bool
Determines whether the debugger is active.
static void
isLive ()
static bool
Determines whether a server is running in production mode.
static ArrayObject
loadConfig ([string|Nette\Config\Config $file = NULL])
Loads global configuration from file and process it.
static void
setConfigurator (Configurator $configurator)
Sets "class behind Environment" configurator.
static void
setMode (string $mode, [bool $flag = TRUE])
Sets the mode.
static void
setName (string $name)
Sets the current environment name.
static void
setVariable (string $name, mixed $value, [bool $expand = TRUE])
Sets the environment variable.
Constant Summary
string CONSOLE 'console'

line 35

environment name
string DEBUG 'debug'

line 40

mode name
string DEVELOPMENT 'development'

line 33

environment name
string LAB 'lab'

line 36

environment name
string PERFORMANCE 'performance'

line 41

mode name
string PRODUCTION 'production'

line 34

environment name

Method Details

line 74

__construct

public Environment __construct ()

Static class - cannot be instantiated.

Output
Environment  

line 302

expand

public static string expand (string $var)

Returns expanded variable.

Input
string $var
Output
string  
Throws
throws InvalidStateException

line 282

exportConstant

public static void exportConstant (string|array $names)

Define one or more variables as constants.

Input
string|array $names
Output
void  

line 403

getApplication

public static Application getApplication ()

Output
Application  

line 428

getCache

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

Input
string $namespace
Output
Cache  

line 473

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 97

getConfigurator

public static Configurator getConfigurator ()

Gets "class behind Environment" configurator.

Output
Configurator  

line 383

getHttpRequest

public static IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 393

getHttpResponse

public static IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 166

getMode

public static bool getMode (string $mode)

Returns the mode.

Input
string $mode mode identifier
Output
bool  

line 133

getName

public static string getName ()

Returns the current environment name.

Output
string  

line 373

getService

public static mixed getService (string $name, [bool $need = TRUE])

Gets the service object of the specified type.

Input
string $name service name
bool $need throw exception if service doesn't exist?
Output
mixed  

line 357

getServiceLocator

public static IServiceLocator getServiceLocator ()

Get initial instance of service locator.

Output
IServiceLocator  

line 443

getSession

public static Session|Nette\Web\Session getSession ([string $namespace = NULL])

Returns instance of session or session namespace.

Input
string $namespace
Output
Session|Nette\Web\Session  

line 413

getUser

public static IUser getUser ()

Output
IUser  

line 251

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 183

isConsole

public static bool isConsole ()

Detects console (non-HTTP) mode.

Output
bool  

line 216

isDebugging

public static bool isDebugging ()

Determines whether the debugger is active.

Output
bool  

line 204

isLive

public static void isLive ()

Output
void  
Tags
Deprecated Environment::isProduction()

line 194

isProduction

public static bool isProduction ()

Determines whether a server is running in production mode.

Output
bool  

line 460

loadConfig

public static ArrayObject loadConfig ([string|Nette\Config\Config $file = NULL])

Loads global configuration from file and process it.

Input
string|Nette\Config\Config $file file name or Config object
Output
ArrayObject  

line 86

setConfigurator

public static void setConfigurator (Configurator $configurator)

Sets "class behind Environment" configurator.

Input
Configurator $configurator
Output
void  

line 152

setMode

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

Sets the mode.

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

line 117

setName

public static void setName (string $name)

Sets the current environment name.

Input
string $name
Output
void  
Throws
throws InvalidStateException

line 234

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