Fix indent ++

This commit is contained in:
BuildTools 2019-11-03 17:51:31 +01:00
parent d45f81a515
commit 541c5820bc
16 changed files with 415 additions and 417 deletions

View file

@ -78,113 +78,112 @@ class Config
}
public function save()
{
if (empty($this->modified))
return true;
{
if (empty($this->modified))
return true;
$values = [];
$db = DB::getInstance();
// $db->begin();
$values = [];
$db = DB::getInstance();
// $db->begin();
foreach ($this->modified as $key=>$modified)
{
$value = $this->config[$key];
var_dump($value);
foreach ($this->modified as $key=>$modified)
{
$value = $this->config[$key];
if (is_array($value))
{
$value = implode(',', $value);
}
elseif (is_object($value))
{
$value = (string) $value;
}
if (is_array($value))
{
$value = implode(',', $value);
}
elseif (is_object($value))
{
$value = (string) $value;
}
$db->exec('INSERT OR REPLACE INTO plugin_facturation_config (cle, valeur) VALUES (\''.$key.'\', \''.$value.'\');');
$db->exec('INSERT OR REPLACE INTO plugin_facturation_config (cle, valeur) VALUES (\''.$key.'\', \''.$value.'\');');
}
// $db->commit();
$this->modified = [];
// $db->commit();
return true;
$this->modified = [];
return true;
}
public function set($key, $value)
{
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (is_array($this->fields_types[$key]))
{
$value = !empty($value) ? (array) $value : [];
}
elseif (is_int($this->fields_types[$key]))
{
$value = (int) $value;
}
elseif (is_float($this->fields_types[$key]))
{
$value = (float) $value;
}
elseif (is_bool($this->fields_types[$key]))
{
$value = (bool) $value;
}
elseif (is_string($this->fields_types[$key]))
{
$value = (string) $value;
}
if (is_array($this->fields_types[$key]))
{
$value = !empty($value) ? (array) $value : [];
}
elseif (is_int($this->fields_types[$key]))
{
$value = (int) $value;
}
elseif (is_float($this->fields_types[$key]))
{
$value = (float) $value;
}
elseif (is_bool($this->fields_types[$key]))
{
$value = (bool) $value;
}
elseif (is_string($this->fields_types[$key]))
{
$value = (string) $value;
}
// switch ($key)
// {
// case 'siret_asso':
// {
// if (!trim($value))
// {
// throw new UserException('Le nom de l\'association ne peut rester vide.');
// }
// break;
// }
// case 'footer':
// break;
// default:
// break;
// }
// switch ($key)
// {
// case 'siret_asso':
// {
// if (!trim($value))
// {
// throw new UserException('Le nom de l\'association ne peut rester vide.');
// }
// break;
// }
// case 'footer':
// break;
// default:
// break;
// }
if (!isset($this->config[$key]) || $value !== $this->config[$key])
{
$this->config[$key] = $value;
$this->modified[$key] = true;
}
if (!isset($this->config[$key]) || $value !== $this->config[$key])
{
$this->config[$key] = $value;
$this->modified[$key] = true;
}
return true;
return true;
}
public function get($key)
{
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (!array_key_exists($key, $this->config))
{
return null;
}
return $this->config[$key];
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (!array_key_exists($key, $this->config))
{
return null;
}
return $this->config[$key];
}
public function getFieldsTypes()
{
return $this->fields_types;
return $this->fields_types;
}
public function getConfig()
{
return $this->config;
return $this->config;
}
}
}