mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 14:08:40 +00:00
Implement admin controller api test
This commit is contained in:
parent
879691d68d
commit
e556fbed49
|
|
@ -56,7 +56,7 @@ trait OptionsTrait
|
||||||
*/
|
*/
|
||||||
public function setOption($key, $value, bool $overwrite = true) : bool
|
public function setOption($key, $value, bool $overwrite = true) : bool
|
||||||
{
|
{
|
||||||
if ($overwrite || !array_key_exists($key, $this->options)) {
|
if ($overwrite || !isset($this->options[$key])) {
|
||||||
$this->options[$key] = $value;
|
$this->options[$key] = $value;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ abstract class SettingsAbstract implements OptionsInterface
|
||||||
* @return mixed Option value
|
* @return mixed Option value
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
|
* @todo: don't db request if exists. check exists()
|
||||||
*/
|
*/
|
||||||
public function get($columns)
|
public function get($columns)
|
||||||
{
|
{
|
||||||
|
|
@ -110,7 +111,7 @@ abstract class SettingsAbstract implements OptionsInterface
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $options;
|
return count($options) > 1 ? $options : reset($options);
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
$exception = DatabaseExceptionFactory::createException($e);
|
$exception = DatabaseExceptionFactory::createException($e);
|
||||||
$message = DatabaseExceptionFactory::createExceptionMessage($e);
|
$message = DatabaseExceptionFactory::createExceptionMessage($e);
|
||||||
|
|
@ -134,7 +135,16 @@ abstract class SettingsAbstract implements OptionsInterface
|
||||||
$this->setOptions($options);
|
$this->setOptions($options);
|
||||||
|
|
||||||
if ($store) {
|
if ($store) {
|
||||||
// save to db
|
foreach($this->options as $key => $option) {
|
||||||
|
$query = new Builder($this->connection);
|
||||||
|
$sql = $query->update($this->connection->prefix . static::$table)
|
||||||
|
->set([static::$columns[1] => $option])
|
||||||
|
->where(static::$columns[0], '=', $key)
|
||||||
|
->toSql();
|
||||||
|
|
||||||
|
$sth = $this->connection->con->prepare($sql);
|
||||||
|
$sth->execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user