Skip to content

Commit

Permalink
Update Module.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisnikoy committed Jun 1, 2024
1 parent 88d6cd4 commit 875dab1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,20 @@ public function loadModule(string $moduleName, string $moduleAction = null): voi
*/
private function moduleExists(): bool {
foreach ($this->config->get('module_dirs') as $directory) {
if (file_exists($directory . strtolower($this->moduleName) . '/views/' . strtolower($this->moduleName) . '.html')) {
$this->viewDir = $directory . strtolower($this->moduleName) . '/views/';
}

$moduleControllerFile = $directory . strtolower($this->moduleName) . '/controllers/' . ucfirst(isset($this->moduleAction) ? $this->moduleAction : $this->moduleName) . 'Controller.php';
$standaloneControllerFile = $directory . ucfirst($this->moduleName) . 'Controller.php';
$mainControllerFile = $directory . strtolower($this->moduleName) . '/controllers/' . ucfirst($this->moduleName) . 'Controller.php';
$dataControllerFile = $directory . strtolower($this->moduleName) . '/data/' . ucfirst(isset($this->moduleAction) ? $this->moduleAction : $this->moduleName) . 'Controller.php';

if(file_exists($dataControllerFile)) {
$this->moduleDir = $directory;
$this->moduleFile = $dataControllerFile;
return true;
}

if (file_exists($directory . strtolower($this->moduleName) . '/views/' . strtolower($this->moduleName) . '.html')) {
$this->viewDir = $directory . strtolower($this->moduleName) . '/views/';
}

if (file_exists($moduleControllerFile)) {
$this->moduleDir = $directory . strtolower($this->moduleName) . '/controllers/';
Expand Down

0 comments on commit 875dab1

Please sign in to comment.