\midcom_baseclasses_components_configuration

Configuration class for components.

Summary

Methods
Properties
Constants
get()
set()
read_array_from_file()
read_array_from_snippet()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
_initialize()
_load_configuration()
$_data
N/A

Properties

$_data

$_data : array

Component specific global data storage area, which should be used for stuff like default configurations etc. thus avoiding the pollution of the global namespace. Each component has its own array in the global one, allowing storage of arbitrary data indexed by arbitrary keys in there. The component-specific arrays are indexed by their name.

Note, that this facility is quite a different thing to the component context from midcom_application, even if it has many similar applications. The component context is only available and valid for components, which are actually handling a request. This data storage area is static to the complete component and shared over all subrequests and therefore suitable to hold default configurations, -schemas and the like.

Type

array

Methods

get()

get(  $component,   $key = null) 

Parameters

$component
$key

set()

set(  $component,   $key,   $value) 

Parameters

$component
$key
$value

read_array_from_file()

read_array_from_file(string  $filename) : Array

Read a file from disk and evaluate its content as array.

This is essentially a simple [$data\n] eval construct.

If the file does not exist, false is returned.

Parameters

string $filename

The name of the file that should be parsed.

Returns

Array —

The read data or false on failure.

read_array_from_snippet()

read_array_from_snippet(string  $snippetpath) : Array

Read a snippet and evaluate its content as array.

This is essentially a simple [$data\n] eval construct.

If the snippet does not exist, false is returned.

Parameters

string $snippetpath

The full path to the snippet that should be returned.

Returns

Array —

The read data or false on failure.

_initialize()

_initialize(  $component) 

Initialize the global data storage

Parameters

$component

_load_configuration()

_load_configuration(  $component) 

Loads the configuration file specified by the component configuration and constructs a midcom_helper_configuration object out of it. Both Component defaults and sitegroup-configuration gets merged. The resulting object is stored under the key 'config' in the component's data storage area.

Three files will be loaded in order:

  1. The component's default configuration, placed in $prefix/config/config.inc
  2. Any systemwide default configuration, currently placed in midcom::get()->config->get('midcom_config_basedir')/midcom/$component/config.inc.
  3. Any site configuration in the snippet midcom::get()->config->get('midcom_sgconfig_basedir')/$component/config.

Parameters

$component