diff --git a/Application/ApplicationManager.php b/Application/ApplicationManager.php index 4a1172fc1..836f577ad 100644 --- a/Application/ApplicationManager.php +++ b/Application/ApplicationManager.php @@ -118,7 +118,7 @@ final class ApplicationManager // @var class-string $class $class = \str_replace('/', '\\', $classPath); - $class::install($this->app->dbPool, $info, $this->app->appSettings); + $class::install($this->app, $info, $this->app->appSettings); return true; } catch (\Throwable $t) { @@ -150,7 +150,7 @@ final class ApplicationManager // @var class-string $class $class = \str_replace('/', '\\', $classPath); - $class::uninstall($this->app->dbPool, $info, $this->app->appSettings); + $class::uninstall($this->app, $info, $this->app->appSettings); $this->uninstallFiles($source); diff --git a/Application/InstallerAbstract.php b/Application/InstallerAbstract.php index f2e4cc67a..67cb31bf3 100644 --- a/Application/InstallerAbstract.php +++ b/Application/InstallerAbstract.php @@ -41,7 +41,7 @@ abstract class InstallerAbstract /** * Install app. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ApplicationInfo $info App info * @param SettingsInterface $cfgHandler Settings/Configuration handler * @@ -49,10 +49,10 @@ abstract class InstallerAbstract * * @since 1.0.0 */ - public static function install(DatabasePool $dbPool, ApplicationInfo $info, SettingsInterface $cfgHandler) : void + public static function install(ApplicationAbstract $app, ApplicationInfo $info, SettingsInterface $cfgHandler) : void { - self::createTables($dbPool, $info); - self::activate($dbPool, $info); + self::createTables($app->dbPool, $info); + self::activate($app, $info); self::installTheme(static::PATH . '/..', 'Default'); } @@ -125,14 +125,14 @@ abstract class InstallerAbstract /** * Activate after install. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ApplicationInfo $info App info * * @return void * * @since 1.0.0 */ - protected static function activate(DatabasePool $dbPool, ApplicationInfo $info) : void + protected static function activate(ApplicationAbstract $app, ApplicationInfo $info) : void { if (($path = \realpath(static::PATH)) === false) { return; // @codeCoverageIgnore @@ -147,7 +147,7 @@ abstract class InstallerAbstract throw new \UnexpectedValueException($class); // @codeCoverageIgnore } - $class::activate($dbPool, $info); + $class::activate($app, $info); } /** diff --git a/Module/InstallerAbstract.php b/Module/InstallerAbstract.php index f2f3a28a7..4ce6961a9 100644 --- a/Module/InstallerAbstract.php +++ b/Module/InstallerAbstract.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace phpOMS\Module; +use phpOMS\Application\ApplicationAbstract; use phpOMS\Application\ApplicationInfo; use phpOMS\Autoloader; use phpOMS\Config\SettingsInterface; @@ -41,7 +42,7 @@ abstract class InstallerAbstract /** * Install module. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * @param SettingsInterface $cfgHandler Settings/Configuration handler * @@ -49,10 +50,10 @@ abstract class InstallerAbstract * * @since 1.0.0 */ - public static function install(DatabasePool $dbPool, ModuleInfo $info, SettingsInterface $cfgHandler) : void + public static function install(ApplicationAbstract $app, ModuleInfo $info, SettingsInterface $cfgHandler) : void { - self::createTables($dbPool, $info); - self::activate($dbPool, $info); + self::createTables($app->dbPool, $info); + self::activate($app, $info); } /** @@ -86,14 +87,14 @@ abstract class InstallerAbstract /** * Activate after install. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * * @return void * * @since 1.0.0 */ - protected static function activate(DatabasePool $dbPool, ModuleInfo $info) : void + protected static function activate(ApplicationAbstract $app, ModuleInfo $info) : void { if (($path = \realpath(static::PATH)) === false) { return; // @codeCoverageIgnore @@ -108,7 +109,7 @@ abstract class InstallerAbstract throw new \UnexpectedValueException($class); // @codeCoverageIgnore } - $class::activate($dbPool, $info); + $class::activate($app, $info); } /** diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index 99833da8c..2125d2b53 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -398,7 +398,7 @@ final class ModuleManager } /** @var $class DeactivateAbstract */ - $class::deactivate($this->app->dbPool, $info); + $class::deactivate($this->app, $info); } /** @@ -450,7 +450,7 @@ final class ModuleManager } /** @var $class ActivateAbstract */ - $class::activate($this->app->dbPool, $info); + $class::activate($this->app, $info); } /** @@ -568,7 +568,7 @@ final class ModuleManager } /** @var $class UninstallerAbstract */ - $class::uninstall($this->app->dbPool, $info); + $class::uninstall($this->app, $info); if (isset($this->installed[$module])) { unset($this->installed[$module]); @@ -607,7 +607,7 @@ final class ModuleManager } /** @var InstallerAbstract $class */ - $class::install($this->app->dbPool, $info, $this->app->appSettings); + $class::install($this->app, $info, $this->app->appSettings); } /** @@ -631,7 +631,7 @@ final class ModuleManager $from = \str_replace('/', '\\', $from); $class = $from . '\\Admin\\Install\\' . $for; - $class::install($this->modulePath, $this->app); + $class::install($this->app, $this->modulePath); } /** diff --git a/Module/StatusAbstract.php b/Module/StatusAbstract.php index 6daf5b32a..5acf26d0a 100644 --- a/Module/StatusAbstract.php +++ b/Module/StatusAbstract.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace phpOMS\Module; +use phpOMS\Application\ApplicationAbstract; use phpOMS\Application\ApplicationInfo; use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\System\File\Local\Directory; @@ -46,14 +47,14 @@ abstract class StatusAbstract /** * Deactivate module. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * * @return void * * @since 1.0.0 */ - public static function activate(DatabasePool $dbPool, ModuleInfo $info) : void + public static function activate(ApplicationAbstract $app, ModuleInfo $info) : void { self::activateRoutes($info); self::activateHooks($info); @@ -176,14 +177,14 @@ abstract class StatusAbstract /** * Deactivate module. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * * @return void * * @since 1.0.0 */ - public static function deactivate(DatabasePool $dbPool, ModuleInfo $info) : void + public static function deactivate(ApplicationAbstract $app, ModuleInfo $info) : void { self::deactivateRoutes($info); self::deactivateHooks($info); diff --git a/Module/UninstallerAbstract.php b/Module/UninstallerAbstract.php index ee6b29edd..41fc6a110 100644 --- a/Module/UninstallerAbstract.php +++ b/Module/UninstallerAbstract.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace phpOMS\Module; +use phpOMS\Application\ApplicationAbstract; use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Schema\Builder as SchemaBuilder; @@ -39,31 +40,31 @@ abstract class UninstallerAbstract /** * Install module. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * * @return void * * @since 1.0.0 */ - public static function uninstall(DatabasePool $dbPool, ModuleInfo $info) : void + public static function uninstall(ApplicationAbstract $app, ModuleInfo $info) : void { - self::deactivate($dbPool, $info); - self::dropTables($dbPool, $info); - self::unregisterFromDatabase($dbPool, $info); + self::deactivate($app, $info); + self::dropTables($app->dbPool, $info); + self::unregisterFromDatabase($app->dbPool, $info); } /** * Activate after install. * - * @param DatabasePool $dbPool Database instance + * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * * @return void * * @since 1.0.0 */ - protected static function deactivate(DatabasePool $dbPool, ModuleInfo $info) : void + protected static function deactivate(ApplicationAbstract $app, ModuleInfo $info) : void { if (($path = \realpath(static::PATH)) === false) { return; // @codeCoverageIgnore @@ -74,7 +75,7 @@ abstract class UninstallerAbstract /** @var StatusAbstract $class */ $class = \str_replace('/', '\\', $classPath); - $class::deactivate($dbPool, $info); + $class::deactivate($app, $info); } /** diff --git a/Uri/UriFactory.php b/Uri/UriFactory.php index 8f84bb256..98beccec3 100644 --- a/Uri/UriFactory.php +++ b/Uri/UriFactory.php @@ -229,7 +229,7 @@ final class UriFactory \parse_str($urlStructure['query'], $urlStructure['query']); foreach ($urlStructure['query'] as $para => $query) { - if ($query === '' && \stripos($url, $para . '=') !== false) { + if (($query === '' && \stripos($url, $para . '=') !== false) || $query === '---') { unset($urlStructure['query'][$para]); } } @@ -249,7 +249,7 @@ final class UriFactory . (isset($urlStructure['path']) && !empty($urlStructure['path']) ? $urlStructure['path'] : '') . (isset($urlStructure['query']) && !empty($urlStructure['query']) - ? '?' . \http_build_query($urlStructure['query']) : '') + ? '?' . \rtrim(\str_replace('=&', '&', \http_build_query($urlStructure['query'])), '=') : '') . (isset($urlStructure['fragment']) && !empty($urlStructure['fragment']) ? '#' . \str_replace('\#', '#', $urlStructure['fragment']) : ''); @@ -288,7 +288,7 @@ final class UriFactory $parsed = \preg_replace_callback('(\{[\/#\?%@\.\$][a-zA-Z0-9\-]*\})', function ($match) use ($toMatch) { $match = \substr($match[0], 1, \strlen($match[0]) - 2); - return $toMatch[$match] ?? self::$uri[$match] ?? ''; + return $toMatch[$match] ?? self::$uri[$match] ?? '---'; }, $uri); return self::unique($parsed ?? ''); diff --git a/tests/Module/InstallerAbstractTest.php b/tests/Module/InstallerAbstractTest.php index e74d8ee7d..d51f1e710 100644 --- a/tests/Module/InstallerAbstractTest.php +++ b/tests/Module/InstallerAbstractTest.php @@ -17,6 +17,7 @@ namespace phpOMS\tests\Module; require_once __DIR__ . '/../Autoloader.php'; use Model\CoreSettings; +use phpOMS\Application\ApplicationAbstract; use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\InstallerAbstract; use phpOMS\Module\ModuleInfo; @@ -49,7 +50,7 @@ final class InstallerAbstractTest extends \PHPUnit\Framework\TestCase $this->expectException(\UnexpectedValueException::class); $this->installer::install( - new DatabasePool(), + new class() extends ApplicationAbstract {}, new ModuleInfo(__DIR__), new CoreSettings() );