|
@@ -13,6 +13,30 @@ class LuticateSettingsBusiness extends LuBusiness {
|
13
|
13
|
return new LuticateSettingsDataAccess();
|
14
|
14
|
}
|
15
|
15
|
|
|
16
|
+ /**
|
|
17
|
+ * @param $setting LuticateSettingsDbo
|
|
18
|
+ */
|
|
19
|
+ public static function checkSetting($setting)
|
|
20
|
+ {
|
|
21
|
+ if (is_null($setting->getValue())) {
|
|
22
|
+ self::notFound("Setting Value cannot be null");
|
|
23
|
+ }
|
|
24
|
+ if (is_null($setting->getType())) {
|
|
25
|
+ self::notFound("Setting Type cannot be null");
|
|
26
|
+ }
|
|
27
|
+ else {
|
|
28
|
+ if (is_array($setting->getValue())) {
|
|
29
|
+ $setting->setValue(json_encode($setting->getValue()));
|
|
30
|
+ }
|
|
31
|
+ }
|
|
32
|
+ if (is_null($setting->getName())) {
|
|
33
|
+ self::notFound("Setting Name cannot be null");
|
|
34
|
+ }
|
|
35
|
+ if (!is_bool($setting->getIsBlocked())) {
|
|
36
|
+ self::notFound("Setting IsBlocked must be boolean");
|
|
37
|
+ }
|
|
38
|
+ }
|
|
39
|
+
|
16
|
40
|
public static function checkSettingName($setting_name)
|
17
|
41
|
{
|
18
|
42
|
$perm = LuticateSettingsDataAccess::getByName($setting_name);
|
|
@@ -53,6 +77,7 @@ class LuticateSettingsBusiness extends LuBusiness {
|
53
|
77
|
*/
|
54
|
78
|
public static function add($setting)
|
55
|
79
|
{
|
|
80
|
+ self::checkSetting($setting);
|
56
|
81
|
$perm = LuticateSettingsDataAccess::getByName($setting->getName());
|
57
|
82
|
if (is_null($perm)) {
|
58
|
83
|
LuticateSettingsDataAccess::add($setting);
|
|
@@ -75,6 +100,8 @@ class LuticateSettingsBusiness extends LuBusiness {
|
75
|
100
|
*/
|
76
|
101
|
public static function edit($setting_name, $setting)
|
77
|
102
|
{
|
|
103
|
+ $setting->setName($setting_name);
|
|
104
|
+ self::checkSetting($setting);
|
78
|
105
|
self::checkSettingName($setting_name);
|
79
|
106
|
LuticateSettingsDataAccess::edit($setting_name, $setting);
|
80
|
107
|
return true;
|