New logic for storage provider (breaking changes)

This commit is contained in:
RainLoop Team 2015-02-05 03:54:26 +04:00
parent 44566aad4b
commit 51666d7c7e
19 changed files with 453 additions and 297 deletions

View file

@ -5,6 +5,7 @@ namespace RainLoop\Providers\Settings;
class DefaultSettings implements \RainLoop\Providers\Settings\SettingsInterface
{
const FILE_NAME = 'settings';
const FILE_NAME_LOCAL = 'settings_local';
/**
* @var \RainLoop\Providers\Storage
@ -28,7 +29,10 @@ class DefaultSettings implements \RainLoop\Providers\Settings\SettingsInterface
{
$sValue = $this->oStorageProvider->Get($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME);
$this->oStorageProvider->IsLocal() ?
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME_LOCAL :
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME
);
$aSettings = array();
if (\is_string($sValue))
@ -53,19 +57,23 @@ class DefaultSettings implements \RainLoop\Providers\Settings\SettingsInterface
{
return $this->oStorageProvider->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME,
$this->oStorageProvider->IsLocal() ?
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME_LOCAL :
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME,
\json_encode($aSettings));
}
/**
* @param string $sEmail
* @param \RainLoop\Model\Account $oAccount
*
* @return bool
*/
public function ClearByEmail($sEmail)
public function Delete($oAccount)
{
return $this->oStorageProvider->Clear($sEmail,
return $this->oStorageProvider->Clear($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME);
$this->oStorageProvider->IsLocal() ?
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME_LOCAL :
\RainLoop\Providers\Settings\DefaultSettings::FILE_NAME);
}
}

View file

@ -20,9 +20,9 @@ interface SettingsInterface
public function Save($oAccount, array $aSettings);
/**
* @param string $sEmail
* @param \RainLoop\Model\Account $oAccount
*
* @return bool
*/
public function ClearByEmail($sEmail);
public function Delete($oAccount);
}