Revert "Replace Module::init() with Constructors"

This commit is contained in:
Hypolite Petovan
2021-11-19 07:23:23 -05:00
committed by GitHub
parent 0b6e0566d7
commit 89d6c89b67
43 changed files with 921 additions and 1225 deletions

View File

@@ -81,7 +81,7 @@ class ModuleController
private $moduleName;
/**
* @var ?ICanHandleRequests The module object
* @var ICanHandleRequests The module object
*/
private $module;
@@ -104,9 +104,9 @@ class ModuleController
}
/**
* @return ?ICanHandleRequests The base module object
* @return ICanHandleRequests The base module object
*/
public function getModule(): ?ICanHandleRequests
public function getModule(): ICanHandleRequests
{
return $this->module;
}
@@ -120,10 +120,12 @@ class ModuleController
return $this->isBackend;
}
public function __construct(string $moduleName = self::DEFAULT, ?ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false)
public function __construct(string $moduleName = self::DEFAULT, ICanHandleRequests $module = null, bool $isBackend = false, bool $printNotAllowedAddon = false)
{
$defaultClass = static::DEFAULT_CLASS;
$this->moduleName = $moduleName;
$this->module = $module;
$this->module = $module ?? new $defaultClass();
$this->isBackend = $isBackend;
$this->printNotAllowedAddon = $printNotAllowedAddon;
}
@@ -295,6 +297,8 @@ class ModuleController
Core\Hook::callAll($this->moduleName . '_mod_init', $placeholder);
$this->module->init();
$profiler->set(microtime(true) - $timestamp, 'init');
if ($server['REQUEST_METHOD'] === Router::DELETE) {