Class Environment (namespace Nette)


Nette environment and configuration.


Copyright: Copyright (c) 2004, 2010 David Grudl
Located: in /Environment.php (line 21)
Public Method Summary
Environment
Static class - cannot be instantiated.
static string
expand (string $var)
Returns expanded variable.
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 HttpContext
static HttpRequest
static HttpResponse
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 Session
getSession ([string $namespace = NULL])
Returns instance of session or session namespace.
static User
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|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 $value = TRUE])
Sets the mode.
static void
setName (string $name)
Sets the current environment name.
static void
setServiceAlias (string $service, string $alias)
Adds new Environment::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 26

environment name
string DEBUG 'debug'

line 31

mode name
string DEVELOPMENT 'development'

line 24

environment name
string LAB 'lab'

line 27

environment name
string PERFORMANCE 'performance'

line 32

mode name
string PRODUCTION 'production'

line 25

environment name

Method Details

line 70

__construct

public Environment __construct ()

Static class - cannot be instantiated.

Output
Environment  

line 280

expand

public static string expand (string $var)

Returns expanded variable.

Input
string $var
Output
string  
Throws
throws InvalidStateException

line 421

getApplication

public static Application getApplication ()

Output
Application  

line 446

getCache

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

Input
string $namespace
Output
Cache  

line 491

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 93

getConfigurator

public static Configurator getConfigurator ()

Gets "class behind Environment" configurator.

Output
Configurator  

line 401

getHttpContext

public static HttpContext getHttpContext ()

Output
HttpContext  

line 391

getHttpRequest

public static HttpRequest getHttpRequest ()

Output
HttpRequest  

line 411

getHttpResponse

public static HttpResponse getHttpResponse ()

Output
HttpResponse  

line 161

getMode

public static bool getMode (string $mode)

Returns the mode.

Input
string $mode mode identifier
Output
bool  

line 129

getName

public static string getName ()

Returns the current environment name.

Output
string  

line 351

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 335

getServiceLocator

public static IServiceLocator getServiceLocator ()

Get initial instance of service locator.

Output
IServiceLocator  

line 461

getSession

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

Returns instance of session or session namespace.

Input
string $namespace
Output
Session  

line 431

getUser

public static User getUser ()

Output
User  

line 233

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 263

getVariables

public static array getVariables ()

Returns the all environment variables.

Output
array  

line 177

isConsole

public static bool isConsole ()

Detects console (non-HTTP) mode.

Output
bool  

line 198

isDebugging

public static void isDebugging ()

Output
void  
Tags
Deprecated

line 188

isProduction

public static bool isProduction ()

Determines whether a server is running in production mode.

Output
bool  

line 478

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 82

setConfigurator

public static void setConfigurator (Configurator $configurator)

Sets "class behind Environment" configurator.

Input
Configurator $configurator
Output
void  

line 148

setMode

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

Sets the mode.

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

line 113

setName

public static void setName (string $name)

Sets the current environment name.

Input
string $name
Output
void  
Throws
throws InvalidStateException

line 364

setServiceAlias

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

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

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

line 216

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 377

__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