@@ -13,7 +13,7 @@ class AppSettings
13
13
/**
14
14
* @var SettingStorage
15
15
*/
16
- private $ settingStorage ;
16
+ protected $ settingStorage ;
17
17
18
18
/**
19
19
* AppSettings constructor.
@@ -22,16 +22,35 @@ class AppSettings
22
22
*/
23
23
public function __construct (SettingStorage $ settingStorage )
24
24
{
25
- $ groupName = $ this ->getSettingsGroupName ();
25
+ $ this ->setSettingStorage ($ settingStorage );
26
+ }
27
+
28
+ /**
29
+ * Sets the settings storage.
30
+ *
31
+ * @param SettingStorage $settingStorage
32
+ */
33
+ public function setSettingStorage (SettingStorage $ settingStorage )
34
+ {
35
+ $ this ->settingStorage = $ settingStorage ;
26
36
37
+ $ groupName = $ this ->getSettingsGroupName ();
27
38
if ( $ groupName && is_callable ($ groupName ) ) {
28
39
$ groupName = $ this ->runCallback ($ groupName , 'setting_group ' , null );
29
- $ this ->settingStorage = $ settingStorage ->group ($ groupName );
30
- } else {
31
- $ this ->settingStorage = $ settingStorage ;
40
+ $ this ->setStorageGroup ($ groupName );
32
41
}
33
42
}
34
43
44
+ /**
45
+ * Sets the current storage group.
46
+ *
47
+ * @param string $groupName
48
+ */
49
+ public function setStorageGroup ($ groupName )
50
+ {
51
+ $ this ->settingStorage ->group ($ groupName );
52
+ }
53
+
35
54
/**
36
55
* Get all the settings from storage
37
56
*
@@ -214,7 +233,7 @@ public function getValidationRules()
214
233
* @param bool $out
215
234
* @return bool|int|mixed|string
216
235
*/
217
- private function castValue ($ dataType , $ value , $ out = false )
236
+ protected function castValue ($ dataType , $ value , $ out = false )
218
237
{
219
238
switch ($ dataType ) {
220
239
case 'array ' :
@@ -285,7 +304,7 @@ protected function cleanUpSettings($allDefinedSettings)
285
304
* @param $out
286
305
* @return array|mixed|string
287
306
*/
288
- private function castToArray ($ value , $ out )
307
+ protected function castToArray ($ value , $ out )
289
308
{
290
309
if ($ out ) {
291
310
return empty ($ value ) ? [] : json_decode ($ value , true );
@@ -301,7 +320,7 @@ private function castToArray($value, $out)
301
320
* @param $request Request
302
321
* @return string|null
303
322
*/
304
- private function uploadFile ($ setting , $ request )
323
+ protected function uploadFile ($ setting , $ request )
305
324
{
306
325
$ settingName = Arr::get ($ setting , 'name ' );
307
326
@@ -337,7 +356,7 @@ private function uploadFile($setting, $request)
337
356
* @param $oldFile
338
357
* @param $disk
339
358
*/
340
- private function deleteFile ($ oldFile , $ disk ): void
359
+ protected function deleteFile ($ oldFile , $ disk ): void
341
360
{
342
361
if ($ oldFile && Storage::disk ($ disk )->exists ($ oldFile )) {
343
362
Storage::disk ($ disk )->delete ($ oldFile );
0 commit comments