Skip to content

Commit d9d9ef0

Browse files
committed
Update
1 parent 98cdb82 commit d9d9ef0

2 files changed

Lines changed: 44 additions & 48 deletions

File tree

‎src/Module.php‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct()
3333
}
3434

3535
/**
36-
* Get modules routes
36+
* Get modules routes.
3737
*
3838
* @access public
3939
* @param void
@@ -44,8 +44,7 @@ public function getModulesRoutes()
4444
$wrapper = [];
4545
if ( $this->getModules() ) {
4646
foreach ( $this->getModules() as $key => $name ) {
47-
$json = new Json("{$name}/module.json");
48-
$config = $json->parse(true);
47+
$config = Json::parse("{$name}/module.json",true);
4948
if ( $config['enable'] == true ) {
5049
foreach ($config['router'] as $route) {
5150
$wrapper[] = $route;
@@ -57,7 +56,7 @@ public function getModulesRoutes()
5756
}
5857

5958
/**
60-
* Add module js
59+
* Add module js.
6160
*
6261
* @access protected
6362
* @param string $js
@@ -73,7 +72,7 @@ protected function addJS($js, $hook = 'add-js')
7372
}
7473

7574
/**
76-
* Add module css
75+
* Add module css.
7776
*
7877
* @access protected
7978
* @param string $css
@@ -89,7 +88,7 @@ protected function addCSS($css, $hook = 'add-css')
8988
}
9089

9190
/**
92-
* Get modules routes
91+
* Get modules routes.
9392
*
9493
* @access private
9594
* @param void
@@ -98,9 +97,8 @@ protected function addCSS($css, $hook = 'add-css')
9897
private function loadModules()
9998
{
10099
foreach ( $this->getModules() as $name ) {
101-
$json = new Json("{$name}/module.json");
102-
Validator::checkModuleConfig($json);
103-
$config = $json->parse();
100+
$config = Json::parse("{$name}/module.json");
101+
Validator::checkModuleConfig($config);
104102
if ( $config->migrate ) {
105103
$configurator = new Configurator();
106104
$configurator->migrate("{$name}/migrate");

‎src/TraitConfiguration.php‎

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ trait TraitConfiguration
3232
private $routes = [];
3333

3434
/**
35-
* Set Config Json File
36-
* Allow Parent Config Access
35+
* Set Config Json File,
36+
* Allow Parent Config Access.
3737
*
3838
* @access protected
3939
* @param void
@@ -43,18 +43,18 @@ protected function initConfig()
4343
{
4444
// Parse Config file
4545
if ( File::exists(($path = $this->getConfigFile())) ) {
46-
$json = new Json($path);
47-
$this->global = Validator::checkConfig($json)->parse();
46+
Validator::checkConfig(($config = Json::parse($path)));
47+
$this->global = $config;
48+
4849
} else {
4950
// Parse Default Config
50-
$json = new Json(dirname(__FILE__).'/bin/config.default.json');
51-
$this->global = $json->parse();
51+
$this->global = Json::parse(dirname(__FILE__).'/bin/config.default.json');
5252
}
5353

5454
// Set routes config
5555
if ( File::exists(($path = $this->getRoutesFile())) ) {
56-
$routes = new Json($path);
57-
$this->routes = Validator::checkRouteConfig($routes)->parse(true);
56+
Validator::checkRouteConfig(($routes = Json::parse($path,true)));
57+
$this->routes = $routes;
5858
}
5959
}
6060

@@ -84,8 +84,7 @@ protected function getConfig($var = null)
8484
*/
8585
protected function updateConfig($options = [], $section = 'options', $args = 64|128|256)
8686
{
87-
$json = new Json($this->getConfigFile());
88-
$config = $json->parse(true);
87+
$config = Json::parse($this->getConfigFile(),true);
8988
foreach ($options as $option => $value) {
9089
if ( isset($config[$section][$option]) ) {
9190
$config[$section][$option] = $value;
@@ -329,7 +328,7 @@ protected function getModules() : array
329328
}
330329

331330
/**
332-
* Get static modules config
331+
* Get static modules config.
333332
*
334333
* @access protected
335334
* @param void
@@ -339,8 +338,7 @@ protected function getModulesConfig() : array
339338
{
340339
$list = [];
341340
foreach ( $this->getModules() as $name ) {
342-
$json = new Json("{$name}/module.json");
343-
$config = $json->parse();
341+
$config = Json::parse("{$name}/module.json");
344342
$list[] = [
345343
'name' => $config->name,
346344
'description' => $config->description,
@@ -352,7 +350,7 @@ protected function getModulesConfig() : array
352350
}
353351

354352
/**
355-
* Get static expire
353+
* Get static expire.
356354
*
357355
* @access protected
358356
* @param void
@@ -364,7 +362,7 @@ protected function getCacheTTL() : int
364362
}
365363

366364
/**
367-
* Get static view extension
365+
* Get static view extension.
368366
*
369367
* @access protected
370368
* @param void
@@ -376,7 +374,7 @@ protected function getViewExtension() : string
376374
}
377375

378376
/**
379-
* Get static base url
377+
* Get static base url.
380378
*
381379
* @access protected
382380
* @param void
@@ -390,7 +388,7 @@ protected function getBaseUrl() : string
390388
}
391389

392390
/**
393-
* Get static assets url
391+
* Get static assets url.
394392
*
395393
* @access protected
396394
* @param void
@@ -403,7 +401,7 @@ protected function getAssetUrl() : string
403401
}
404402

405403
/**
406-
* Get static assets path
404+
* Get static assets path.
407405
*
408406
* @access protected
409407
* @param void
@@ -416,7 +414,7 @@ protected function getAssetPath() : string
416414
}
417415

418416
/**
419-
* Get static front upload url
417+
* Get static front upload url.
420418
*
421419
* @access protected
422420
* @param void
@@ -429,7 +427,7 @@ protected function getFrontUploadUrl() : string
429427
}
430428

431429
/**
432-
* Get static front upload path
430+
* Get static front upload path.
433431
*
434432
* @access protected
435433
* @param void
@@ -442,7 +440,7 @@ protected function getFrontUploadPath() : string
442440
}
443441

444442
/**
445-
* Get static upload url
443+
* Get static upload url.
446444
*
447445
* @access protected
448446
* @param void
@@ -455,7 +453,7 @@ protected function getAdminUploadUrl() : string
455453
}
456454

457455
/**
458-
* Get static admin upload path
456+
* Get static admin upload path.
459457
*
460458
* @access protected
461459
* @param void
@@ -468,7 +466,7 @@ protected function getAdminUploadPath() : string
468466
}
469467

470468
/**
471-
* Get static admin storage path
469+
* Get static admin storage path.
472470
*
473471
* @access protected
474472
* @param string $path
@@ -480,7 +478,7 @@ protected function getStoragePath($path = 'Storage') : string
480478
}
481479

482480
/**
483-
* Get static public path
481+
* Get static public path.
484482
*
485483
* @access protected
486484
* @param string $path
@@ -492,7 +490,7 @@ protected function getPublicPath($path = 'public') : string
492490
}
493491

494492
/**
495-
* Get static admin url
493+
* Get static admin url.
496494
*
497495
* @access protected
498496
* @param void
@@ -504,7 +502,7 @@ protected function getAdminUrl() : string
504502
}
505503

506504
/**
507-
* Get static verify url
505+
* Get static verify url.
508506
*
509507
* @access protected
510508
* @param void
@@ -516,7 +514,7 @@ protected function getVerifyUrl() : string
516514
}
517515

518516
/**
519-
* Get static login url
517+
* Get static login url.
520518
*
521519
* @access protected
522520
* @param void
@@ -528,7 +526,7 @@ protected function getLoginUrl() : string
528526
}
529527

530528
/**
531-
* Get static API username
529+
* Get static API username.
532530
*
533531
* @access protected
534532
* @param void
@@ -540,7 +538,7 @@ protected function getApiUsername() : string
540538
}
541539

542540
/**
543-
* Get static API password
541+
* Get static API password.
544542
*
545543
* @access protected
546544
* @param void
@@ -552,7 +550,7 @@ protected function getApiPassword() : string
552550
}
553551

554552
/**
555-
* Get static allowed Access
553+
* Get static allowed Access.
556554
*
557555
* @access protected
558556
* @param void
@@ -564,7 +562,7 @@ protected function getAllowedAccess() : array
564562
}
565563

566564
/**
567-
* Get static denied Access
565+
* Get static denied Access.
568566
*
569567
* @access protected
570568
* @param void
@@ -576,7 +574,7 @@ protected function getDeniedAccess() : array
576574
}
577575

578576
/**
579-
* Get static session ID
577+
* Get static session ID.
580578
*
581579
* @access protected
582580
* @param void
@@ -588,7 +586,7 @@ protected function getSessionId() : string
588586
}
589587

590588
/**
591-
* Get static access expire
589+
* Get static access expire.
592590
*
593591
* @access protected
594592
* @param void
@@ -600,7 +598,7 @@ protected function getAccessExpire() : int
600598
}
601599

602600
/**
603-
* Get static secret
601+
* Get static secret.
604602
*
605603
* @access protected
606604
* @param bool $api
@@ -617,7 +615,7 @@ protected function getSecret($api = false) : string
617615
}
618616

619617
/**
620-
* Get static permissions status
618+
* Get static permissions status.
621619
*
622620
* @access protected
623621
* @param void
@@ -629,7 +627,7 @@ protected function isPermissions() : bool
629627
}
630628

631629
/**
632-
* Get static debug status
630+
* Get static debug status.
633631
*
634632
* @access protected
635633
* @param void
@@ -641,7 +639,7 @@ protected function isDebug() : bool
641639
}
642640

643641
/**
644-
* Get static config file path
642+
* Get static config file path.
645643
*
646644
* @access protected
647645
* @param void
@@ -653,7 +651,7 @@ protected function getConfigFile() : string
653651
}
654652

655653
/**
656-
* Get static routes file path
654+
* Get static routes file path.
657655
*
658656
* @access protected
659657
* @param void
@@ -665,7 +663,7 @@ protected function getRoutesFile() : string
665663
}
666664

667665
/**
668-
* Get static database file path
666+
* Get static database file path.
669667
*
670668
* @access protected
671669
* @param void

0 commit comments

Comments
 (0)