diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index 2844a3c5e..927651664 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -100,6 +100,7 @@ class InstallerAbstract { self::registerInDatabase($dbPool, $info); self::initRoutes($modulePath, $info); + self::initHooks($modulePath, $info); self::activate($dbPool, $info); } @@ -133,6 +134,7 @@ class InstallerAbstract public static function reInit(string $modulePath, InfoManager $info) : void { self::initRoutes($modulePath, $info); + self::initHooks($modulePath, $info); } /** @@ -149,7 +151,6 @@ class InstallerAbstract */ private static function initRoutes(string $modulePath, InfoManager $info) : void { - // todo: maybe use static::__DIR__ ? $directories = new Directory($modulePath . '/Admin/Routes'); foreach ($directories as $key => $subdir) { @@ -179,27 +180,90 @@ class InstallerAbstract file_put_contents($destRoutePath, ' $subdir) { + if ($subdir instanceof Directory) { + foreach ($subdir as $key2 => $file) { + self::installHooks(__DIR__ . '/../../' . $subdir->getName() . '/' . basename($file->getName(), '.php') . '/Hooks.php', $file->getPath()); + } } } } + + /** + * Install hooks. + * + * @param string $destHookPath Destination hook path + * @param string $srcHookPath Source hook path + * + * @return void + * + * @throws PermissionException + * + * @since 1.0.0 + */ + private static function installHooks(string $destHookPath, string $srcHookPath) : void + { + if (!file_exists($destHookPath)) { + file_put_contents($destHookPath, '