Skip to content

Commit

Permalink
- Create "customModules" in the DB if it is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
slavenstancic committed Jan 22, 2023
1 parent d59dcf8 commit babbb82
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,7 @@ public function createDb(): void
'password' => password_hash($password, PASSWORD_DEFAULT),
'lastLogins' => [],
'lastModulesSync' => null,
'customModules' => [
'themes' => [],
'plugins' => []
],
'customModules' => $this->defaultCustomModules(),
'menuItems' => [
'0' => [
'name' => 'Home',
Expand Down Expand Up @@ -506,6 +503,17 @@ public function createDb(): void
$this->save();
}

/**
* Default data for the Custom Modules
* @return array[]
*/
private function defaultCustomModules(): array {
return [
'themes' => [],
'plugins' => []
];
}

/**
* Create menu item
*
Expand Down Expand Up @@ -1364,6 +1372,13 @@ private function cacheModulesData(): void

// Cache custom modules
$returnArray = $this->getJsonFileData($this->modulesCachePath);

// If custom modules is missing from the DB, we add it
if (!property_exists($db->config, 'customModules')) {
$this->set('config', 'customModules', $this->defaultCustomModules());
$db = $this->getDb();
}

$arrayCustom = (array)$db->config->customModules;
foreach ($arrayCustom as $type => $modules) {
foreach ($modules as $url) {
Expand Down

0 comments on commit babbb82

Please sign in to comment.