2015-02-01 20:20:54 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace RainLoop;
|
|
|
|
|
|
|
|
class Settings
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $aData;
|
|
|
|
|
2015-03-07 16:14:19 +01:00
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
protected $bLocal;
|
|
|
|
|
2015-02-01 20:20:54 +01:00
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-03-07 16:14:19 +01:00
|
|
|
public function __construct($bLocal = false)
|
2015-02-01 20:20:54 +01:00
|
|
|
{
|
|
|
|
$this->aData = array();
|
2015-03-07 16:14:19 +01:00
|
|
|
$this->bLocal = !!$bLocal;
|
2015-02-01 20:20:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $aData
|
|
|
|
*
|
|
|
|
* @return \RainLoop\Settings
|
|
|
|
*/
|
|
|
|
public function InitData($aData)
|
|
|
|
{
|
|
|
|
if (\is_array($aData))
|
|
|
|
{
|
|
|
|
$this->aData = $aData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function DataAsArray()
|
|
|
|
{
|
|
|
|
return $this->aData;
|
|
|
|
}
|
|
|
|
|
2015-03-07 16:14:19 +01:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function IsLocal()
|
|
|
|
{
|
|
|
|
return $this->bLocal;
|
|
|
|
}
|
|
|
|
|
2015-02-01 20:20:54 +01:00
|
|
|
/**
|
|
|
|
* @param string $sName
|
|
|
|
* @param mixed $mDefValue = null
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function GetConf($sName, $mDefValue = null)
|
|
|
|
{
|
|
|
|
return isset($this->aData[$sName]) ? $this->aData[$sName] : $mDefValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $sName
|
|
|
|
* @param mixed $mValue
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function SetConf($sName, $mValue)
|
|
|
|
{
|
|
|
|
$this->aData[$sName] = $mValue;
|
|
|
|
}
|
|
|
|
}
|