SlaxWeb Framework
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SlaxWeb\Config\Handler Class Reference
Inheritance diagram for SlaxWeb\Config\Handler:
Inheritance graph
[legend]

Public Member Functions

 __construct (array $resDir)
 
 load (string $config, bool $prependResourceName=false)
 
 set (string $key, $value)
 
 get (string $key)
 
 remove (string $key)
 
 exists (string $key)
 
 prependResourceName (array $loadedConfig, string $resName)
 
 addResDir (string $dir)
 
 addResDirs (array $dirs)
 

Public Attributes

const CONFIG_LOADED = 100
 
const CONFIG_RESOURCE_NOT_FOUND = 101
 
const CONFIG_PARSE_ERROR = 102
 

Protected Member Functions

 _getAbsPath (string $resName)
 

Protected Attributes

 $_configValues = []
 
 $_resDir = []
 

Constructor & Destructor Documentation

SlaxWeb\Config\Handler::__construct ( array  $resDir)

Handler constructor

Stores the resource location to the local protected property for later use.

Parameters
array$resDirConfiguration resource locations

Member Function Documentation

SlaxWeb\Config\Handler::_getAbsPath ( string  $resName)
protected

Get resource absolute path

Iterate the Resource Location array and return the absolute path of the resource. Return empty string if resource does not exist in any of the directories.

Parameters
string$resNameName of the resource
Returns
string
SlaxWeb\Config\Handler::addResDir ( string  $dir)

Add Resource Location

Add an additional configuration resource location.

Parameters
string$dirAdditional resource location
Returns
void
SlaxWeb\Config\Handler::addResDirs ( array  $dirs)

Add Resource Locations

Add additional configuration resource locations.

Parameters
array$dirsAdditional resource locations
Returns
void
SlaxWeb\Config\Handler::exists ( string  $key)

Check config item exists

If the config item does not exist, returns false, true otherwise.

Parameters
string$keyConfig item key
Returns
bool
SlaxWeb\Config\Handler::get ( string  $key)

Get config item

Get a config item from the internal config container. On a missing key, return null.

Parameters
string$keyConfig item key
Returns
mixed
SlaxWeb\Config\Handler::load ( string  $config,
bool  $prependResourceName = false 
)
abstract

Load the config

Require the config resource, or load its contents, depending on type of handler that extends this abstract class.

Parameters
string$configName of the config resource
bool$prependResourceNameIf the resource name should be prepended to each config key
Returns
int
SlaxWeb\Config\Handler::prependResourceName ( array  $loadedConfig,
string  $resName 
)

Prepend resource name to keys

Prepends the resource name to the keys defined in loaded configuration array.

Parameters
array$loadedConfigThe loaded config
string$resNameResource name, that is prepended to the keys
Returns
array Loaded config with keys prepended by resource name
SlaxWeb\Config\Handler::remove ( string  $key)

Remove config item

Check if an item with provided key exists, and remove it.

Parameters
string$keyConfig item key
Returns
bool
SlaxWeb\Config\Handler::set ( string  $key,
  $value 
)

Set config item

Set a new config item, ro overwrite an existing item.

Parameters
string$keyConfig item key
mixed$valueConfig item value
Returns
bool

Member Data Documentation

const SlaxWeb\Config\Handler::CONFIG_LOADED = 100

Config was loaded and parsed successfuly

const SlaxWeb\Config\Handler::CONFIG_PARSE_ERROR = 102

Config resource was found, but an error occured while parsing

const SlaxWeb\Config\Handler::CONFIG_RESOURCE_NOT_FOUND = 101

Config resource could not be found


The documentation for this class was generated from the following file: