Class Environment (namespace Nette)


Nette environment and configuration.


Author: David Grudl
Copyright: Copyright (c) 2004, 2009 David Grudl
Located: in /Environment.php (line 32)
Constructor Summary
public
Static class - cannot be instantiated.
Method Summary
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 37

environment name
string DEBUG 'debug'

line 42

mode name
string DEVELOPMENT 'development'

line 35

environment name
string LAB 'lab'

line 38

environment name
string PERFORMANCE 'performance'

line 43

mode name
string PRODUCTION 'production'

line 36

environment name

Constructor Details

line 76

__construct

public __construct ()

Static class - cannot be instantiated.

Method Details

line 303

expand

public static string expand (string $var)

Returns expanded variable.

Input
string $var
Output
string  
Throws
throws InvalidStateException

line 283

exportConstant

public static void exportConstant (string|array $names)

Define one or more variables as constants.

Input
string|array $names
Output
void  

line 404

getApplication

public static Application getApplication ()

Output
Application  

line 429

getCache

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

Input
string $namespace
Output
Cache  

line 474

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 99

getConfigurator

public static Configurator getConfigurator ()

Gets "class behind Environment" configurator.

Output
Configurator  

line 384

getHttpRequest

public static IHttpRequest getHttpRequest ()

Output
IHttpRequest  

line 394

getHttpResponse

public static IHttpResponse getHttpResponse ()

Output
IHttpResponse  

line 168

getMode

public static bool getMode (string $mode)

Returns the mode.

Input
string $mode mode identifier
Output
bool  

line 135

getName

public static string getName ()

Returns the current environment name.

Output
string  

line 374

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 358

getServiceLocator

public static IServiceLocator getServiceLocator ()

Get initial instance of service locator.

Output
IServiceLocator  

line 444

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 414

getUser

public static IUser getUser ()

Output
IUser  

line 252

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 185

isConsole

public static bool isConsole ()

Detects console (non-HTTP) mode.

Output
bool  

line 217

isDebugging

public static bool isDebugging ()

Determines whether the debugger is active.

Output
bool  

line 206

isLive

public static void isLive ()

Output
void  
Tags
Deprecated Environment::isProduction()

line 196

isProduction

public static bool isProduction ()

Determines whether a server is running in production mode.

Output
bool  

line 461

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 88

setConfigurator

public static void setConfigurator (Configurator $configurator)

Sets "class behind Environment" configurator.

Input
Configurator $configurator
Output
void  

line 154

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 119

setName

public static void setName (string $name)

Sets the current environment name.

Input
string $name
Output
void  
Throws
throws InvalidStateException

line 235

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