dbPool, $info); self::activate($app, $info); } /** * Create tables for module. * * @param DatabasePool $dbPool Database instance * @param ModuleInfo $info Module info * * @return void * * @since 1.0.0 */ protected static function createTables(DatabasePool $dbPool, ModuleInfo $info) : void { $path = static::PATH . '/Install/db.json'; if (!\is_file($path)) { return; } $content = \file_get_contents($path); if ($content === false) { return; // @codeCoverageIgnore } /** @var array[] $definitions */ $definitions = \json_decode($content, true); if (!\is_array($definitions)) { return; // @codeCoverageIgnore } foreach ($definitions as $definition) { SchemaBuilder::createFromSchema($definition, $dbPool->get('schema'))->execute(); } } /** * Activate after install. * * @param ApplicationAbstract $app Application * @param ModuleInfo $info Module info * * @return void * * @throws \UnexpectedValueException * * @since 1.0.0 */ protected static function activate(ApplicationAbstract $app, ModuleInfo $info) : void { if (($path = \realpath(static::PATH)) === false) { return; // @codeCoverageIgnore } $classPath = \substr($path . '/Status', (int) \strlen((string) \realpath(__DIR__ . '/../../'))); /** @var class-string $class */ $class = \strtr($classPath, '/', '\\'); if (!Autoloader::exists($class)) { throw new \UnexpectedValueException($class); // @codeCoverageIgnore } $class::activate($app, $info); } /** * Re-init module. * * @param ModuleInfo $info Module info * @param null|ApplicationInfo $appInfo Application info * * @return void * * @throws \UnexpectedValueException * * @since 1.0.0 */ public static function reInit(ModuleInfo $info, ?ApplicationInfo $appInfo = null) : void { if (($path = \realpath(static::PATH)) === false) { return; // @codeCoverageIgnore } $classPath = \substr($path . '/Status', \strlen((string) \realpath(__DIR__ . '/../../'))); /** @var class-string $class */ $class = \strtr($classPath, '/', '\\'); if (!Autoloader::exists($class)) { throw new \UnexpectedValueException($class); // @codeCoverageIgnore } $class::activateRoutes($info, $appInfo); $class::activateHooks($info, $appInfo); } }