/** * Validate if a database connection can be made * * @param InstallationData $data The form data * @param ExecutionContextInterface $context The forms validation context * * @todo Replace SpoonDatabase */ public function checkDatabaseConnection(InstallationData $data, ExecutionContextInterface $context) { try { // create instance $db = new \SpoonDatabase('mysql', $data->getDbHostname(), $data->getDbUsername(), $data->getDbPassword(), $data->getDbDatabase(), $data->getDbPort()); // test table $table = 'test' . time(); // attempt to create table $db->execute('DROP TABLE IF EXISTS ' . $table); $db->execute('CREATE TABLE ' . $table . ' (id int(11) NOT NULL) ENGINE=MyISAM'); // drop table $db->drop($table); } catch (\Exception $e) { $context->addViolation('Problem with database credentials'); } }
/** * @param InstallationData $data * @return array A list of variables that will be used in installers. */ protected function getInstallerData(InstallationData $data) { return array('default_language' => $data->getDefaultLanguage(), 'default_interface_language' => $data->getDefaultInterfaceLanguage(), 'spoon_debug_email' => $data->getEmail(), 'api_email' => $data->getEmail(), 'site_domain' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'fork.local', 'site_title' => 'Fork CMS', 'smtp_server' => '', 'smtp_port' => '', 'smtp_username' => '', 'smtp_password' => '', 'email' => $data->getEmail(), 'password' => $data->getPassword()); }