@@ -396,27 +396,41 @@ public function getPlugins(): array
396
396
*/
397
397
public function getJsonData (): array
398
398
{
399
- $ data = [];
400
- if (!empty ($ this ->settings )) {
401
- $ data ['config ' ] = $ this ->settings ;
399
+ $ data = [];
400
+ $ config = $ this ->getConfigJsonData ();
401
+
402
+ if (!empty ($ config )) {
403
+ $ data ['config ' ] = $ config ;
402
404
}
403
405
406
+ foreach (Hooks::getValidHooks () as $ hook => $ value ) {
407
+ if ($ this ->hooks [$ hook ]->isEnabled () || $ this ->hooks [$ hook ]->hasActions ()) {
408
+ $ data [$ hook ] = $ this ->hooks [$ hook ]->getJsonData ();
409
+ }
410
+ }
411
+ return $ data ;
412
+ }
413
+
414
+ /**
415
+ * Build the "config" JSON section of the configuration file
416
+ *
417
+ * @return array<string, mixed>
418
+ */
419
+ private function getConfigJsonData (): array
420
+ {
421
+ $ config = !empty ($ this ->settings ) ? $ this ->settings : [];
422
+
404
423
$ runConfigData = $ this ->runConfig ->getJsonData ();
405
424
if (!empty ($ runConfigData )) {
406
- $ data [ ' config ' ] ['run ' ] = $ runConfigData ;
425
+ $ config ['run ' ] = $ runConfigData ;
407
426
}
408
427
if (!empty ($ this ->plugins )) {
409
- $ data [ ' config ' ] ['plugins ' ] = $ this ->getPluginsJsonData ();
428
+ $ config ['plugins ' ] = $ this ->getPluginsJsonData ();
410
429
}
411
430
if (!empty ($ this ->custom )) {
412
- $ data [ ' config ' ] ['custom ' ] = $ this ->custom ;
431
+ $ config ['custom ' ] = $ this ->custom ;
413
432
}
414
- foreach (Hooks::getValidHooks () as $ hook => $ value ) {
415
- if ($ this ->hooks [$ hook ]->isEnabled () || $ this ->hooks [$ hook ]->hasActions ()) {
416
- $ data [$ hook ] = $ this ->hooks [$ hook ]->getJsonData ();
417
- }
418
- }
419
- return $ data ;
433
+ return $ config ;
420
434
}
421
435
422
436
/**
0 commit comments