value}"); try { Database::getConnection()->exec(file_get_contents(Resources::getDatabaseResource($object))); } catch (PDOException $e) { // Check if the error code is for "table already exists" if ($e->getCode() === '42S01') { Log::warning('net.nosial.socialbox', "Database object {$object->value} already exists, skipping..."); continue; } else { Log::error('net.nosial.socialbox', "Failed to initialize database object {$object->value}: {$e->getMessage()}", $e); return 1; } } catch(\Exception $e) { Log::error('net.nosial.socialbox', "Failed to initialize database object {$object->value}: {$e->getMessage()}", $e); return 1; } } Log::info('net.nosial.socialbox', 'Socialbox has been initialized successfully'); return 0; } /** * Returns the help message for the command. * * @return string The help message. */ public static function getHelpMessage(): string { return "Initialize Command - Initializes Socialbox for first-runs\n" . "Usage: socialbox init [arguments]\n\n" . "Arguments:\n" . " --force - Forces the initialization process to run even the instance is disabled\n"; } /** * Returns a short help message for the command. * * @return string */ public static function getShortHelpMessage(): string { return "Initializes Socialbox for first-runs"; } }