Cascade Core  v0.12-1-g22cbbeb
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Member Functions | List of all members
Context Class Reference

Context maintains global environment and acts as resource container. More...

Public Member Functions

 __construct (array $resource_factories_config)
 Constructor.
 
 setDefaultLocale ($locale)
 Set locale which will be used as fallback when setting new locale.
 
 __get ($resource_name)
 Lazily create requested resource and store it as public property, so this is called only once per resource. More...
 

Protected Member Functions

 setupTranslator ()
 Setup translator: Bind gettext domain.
 

For blocks

 setLocale ($locale)
 Set gettext locale, the global environment will be updated at next updateEnviroment() call.
 

For Cascade controller

 updateEnviroment ()
 Update enviroment from context, returns true if changes required (for child classes)
 

Detailed Description

Context maintains global environment and acts as resource container.

It is created during initialization and then passed to all block storages (IBlockStorage) and to CascadeController. From CascadeController it is accessible to all Block instances in the cascade.

The Context has two jobs to do:

  1. Setup gettext and maintan context switches.
  2. Keep and create resources.

Just before block is executed Context::updateEnviroment() is called.

Resources are created lazily, when they are requested for the first time.

Resources specified in 'resources' option are dereferenced and passed as regular (top-level) options within the rest of factory configuration.

Warning
Context SHOULD be treated as read-only structure.

Member Function Documentation

__get (   $resource_name)

Lazily create requested resource and store it as public property, so this is called only once per resource.

Todo:
implement lazy loading