2014-08-14 04:40:56 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace RainLoop\Providers;
|
|
|
|
|
|
|
|
class Settings extends \RainLoop\Providers\AbstractProvider
|
|
|
|
{
|
|
|
|
/**
|
2015-02-13 01:54:12 +08:00
|
|
|
* @var \RainLoop\Providers\Settings\ISettings
|
2014-08-14 04:40:56 +08:00
|
|
|
*/
|
|
|
|
private $oDriver;
|
|
|
|
|
|
|
|
/**
|
2015-02-13 01:54:12 +08:00
|
|
|
* @param \RainLoop\Providers\Settings\ISettings $oDriver
|
2014-08-14 04:40:56 +08:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2015-02-13 01:54:12 +08:00
|
|
|
public function __construct(\RainLoop\Providers\Settings\ISettings $oDriver)
|
2014-08-14 04:40:56 +08:00
|
|
|
{
|
|
|
|
$this->oDriver = $oDriver;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-13 06:09:14 +08:00
|
|
|
* @param \RainLoop\Model\Account $oAccount
|
2014-08-14 04:40:56 +08:00
|
|
|
*
|
|
|
|
* @return \RainLoop\Settings
|
|
|
|
*/
|
2014-11-13 06:09:14 +08:00
|
|
|
public function Load(\RainLoop\Model\Account $oAccount)
|
2014-08-14 04:40:56 +08:00
|
|
|
{
|
|
|
|
$oSettings = new \RainLoop\Settings();
|
|
|
|
$oSettings->InitData($this->oDriver->Load($oAccount));
|
|
|
|
return $oSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-11-13 06:09:14 +08:00
|
|
|
* @param \RainLoop\Model\Account $oAccount
|
2014-08-14 04:40:56 +08:00
|
|
|
* @param \RainLoop\Settings $oSettings
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2014-11-13 06:09:14 +08:00
|
|
|
public function Save(\RainLoop\Model\Account $oAccount, \RainLoop\Settings $oSettings)
|
2014-08-14 04:40:56 +08:00
|
|
|
{
|
|
|
|
return $this->oDriver->Save($oAccount, $oSettings->DataAsArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function IsActive()
|
|
|
|
{
|
2015-02-13 01:54:12 +08:00
|
|
|
return $this->oDriver instanceof \RainLoop\Providers\Settings\ISettings;
|
2014-08-14 04:40:56 +08:00
|
|
|
}
|
|
|
|
}
|