PowerKiKi /
mqueue
| 1 | <?php |
||
| 2 | |||
| 3 | namespace mQueue\Model; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Settings stored in database (not to be confused with application configuration) |
||
| 7 | */ |
||
| 8 | class Setting extends AbstractModel |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Returns the setting, with a default value set if none was found. |
||
| 12 | * |
||
| 13 | * @param string $id unique name of setting |
||
| 14 | * @param mixed $defaultValue |
||
| 15 | * |
||
| 16 | * @return Setting |
||
| 17 | */ |
||
| 18 | public static function get($id, $defaultValue) |
||
| 19 | { |
||
| 20 | $setting = SettingMapper::find($id, $defaultValue); |
||
| 21 | |||
| 22 | return $setting; |
||
| 23 | } |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Defines the value of the setting |
||
| 27 | * |
||
| 28 | * @param string $id unique name of setting |
||
| 29 | * @param string $value the value to be set |
||
| 30 | */ |
||
| 31 | public static function set($id, $value): void |
||
| 32 | { |
||
| 33 | $setting = self::get($id, $value); |
||
| 34 | $setting->value = $value; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 35 | $setting->save(); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |