tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Class: Config_Loader

Source Location: /core/config_loader.class.php

Class Config_Loader

Class Overview

Base class for configuration loaders.

Base class for all classes of Config_Loader family. Used to define the interface. Config_Loader classes are intended to provide unified mechanism for loading configuration from diferent sources as files, db, net connection, etc.

Located in /core/config_loader.class.php [line 30]

Tangra_Class
   |
   --Config_Loader
Author(s):
API Tags:
Abstract:  

Properties

Methods

[ Top ]
Descendants
Child Class Description
Config_Loader_File Loads configuration data from file.

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Tangra_Class

Tangra_Class::get_class_name()
Alias of get_class(). Exist because of historical reasons.
Tangra_Class::__set()
Overides PHP built-in method and just throws exception if called. Purpose - to "forbid" autosetting of nonexisting class properties.

[ Top ]
Property Summary
array   $pairs   $pairs holds key - value pairs in associative array. Key is the name of configuration value and value - the value itself.

[ Top ]
Method Summary
Config_Loader   __construct()   It is supposed loading of the configuration from external resource as file or DB to be performed at construction time of Config_Loader objects.
void   add_pair()   Adds new key-value pair
string   expand()   Expands keys that are present in values
string   extract_key()   Extracts single key that start at position $start in string $value
array   extract_keys()   Extracts all keys (delimited by % from both sides)
unknown   get_conf_value()   Gets coresponding to $key configuration value.
array   get_pairs()   Returns all key-value pairs
void   set_pairs()   Auxiliary method that may be used to set the internal private $pairs variable.

[ Top ]
Properties
array   $pairs = array() [line 36]

$pairs holds key - value pairs in associative array. Key is the name of configuration value and value - the value itself.

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 45]

  Config_Loader __construct( mutable $config_resource  )

It is supposed loading of the configuration from external resource as file or DB to be performed at construction time of Config_Loader objects.

That means that when you createn new instance of Config_Loader class (some descendant of Config_Loader that is not "abstract") your configuration will be loaded and you can use get_conf_value method to extract values.

Parameters:
mutable   $config_resource:  Intended to be mutable type, i.e. different Config_Loader descendants may require different paramter type.

API Tags:
Abstract:  


Redefined in descendants as:

[ Top ]
add_pair  [line 183]

  void add_pair( string $key, string $value  )

Adds new key-value pair

Parameters:
string   $key: 
string   $value: 

API Tags:
Access:  public


[ Top ]
expand  [line 110]

  string expand( string $value, string $current_key  )

Expands keys that are present in values

If key starts with _AUTO a global function will be called to return the value. Name of the global function have to be strtolower($key) where $key is the key to be expanded. Example: If we have in machine_specific.conf the following: ROOT=%_AUTO_DETECT_ROOT% function with name _auto_detect_root will be called and returned value will be used to replace %_AUTO_DETECT_ROOT%

Parameters:
string   $value: 
string   $current_key: 

API Tags:
Access:  protected


[ Top ]
extract_key  [line 165]

  string extract_key( string $value, integer $start  )

Extracts single key that start at position $start in string $value

Parameters:
string   $value: 
integer   $start: 

API Tags:
Internal:  
Access:  private


[ Top ]
extract_keys  [line 146]

  array extract_keys( string $value  )

Extracts all keys (delimited by % from both sides)

Parameters:
string   $value: 

API Tags:
Internal:  
Access:  private


[ Top ]
get_conf_value  [line 56]

  unknown get_conf_value( string $key, [boolean $halt_on_missing = true]  )

Gets coresponding to $key configuration value.

Parameters:
boolean   $halt_on_missing:  if true exception will be trown if configuration setting specified by $key
string   $key:  key name of configuration setting

API Tags:
Access:  public

Information Tags:
Throws:  TE_Config_Loader_Error_Key_Missing

[ Top ]
get_pairs  [line 92]

  array get_pairs( )

Returns all key-value pairs


API Tags:
Access:  public


[ Top ]
set_pairs  [line 78]

  void set_pairs( array $pairs  )

Auxiliary method that may be used to set the internal private $pairs variable.

This method normally is not called directly - it is intended to be used by writers of new Config_Loader descendants that require weird approach.

Parameters:
array   $pairs:  Array must be simple associative array with $key => $value structure.

API Tags:
Access:  public

Information Tags:
Throws:  Tangra_Exception

[ Top ]