From 44c91099cd77138bb5fc29f14fb1e81a9781272d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 22 Jan 2019 22:03:47 +0100 Subject: [PATCH] Get rid of DefaultsDataProvider Since we do not provide a development VM anymore, it does not make sense to have "default" credentials etc. To reproduce something similar, I'd suggest using a YAML or JSON file together with the `--file` option. --- src/Install/Console/DefaultsDataProvider.php | 96 -------------------- src/Install/Console/FileDataProvider.php | 26 ++++-- src/Install/Console/InstallCommand.php | 10 +- 3 files changed, 20 insertions(+), 112 deletions(-) delete mode 100644 src/Install/Console/DefaultsDataProvider.php diff --git a/src/Install/Console/DefaultsDataProvider.php b/src/Install/Console/DefaultsDataProvider.php deleted file mode 100644 index 119e657a43..0000000000 --- a/src/Install/Console/DefaultsDataProvider.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Install\Console; - -class DefaultsDataProvider implements DataProviderInterface -{ - protected $databaseConfiguration = [ - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'flarum', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'port' => '3306', - 'strict' => false, - ]; - - protected $debug = false; - - protected $baseUrl = 'http://flarum.local'; - - protected $adminUser = [ - 'username' => 'admin', - 'password' => 'password', - 'password_confirmation' => 'password', - 'email' => 'admin@example.com', - ]; - - protected $settings = []; - - public function getDatabaseConfiguration() - { - return $this->databaseConfiguration; - } - - public function setDatabaseConfiguration(array $databaseConfiguration) - { - $this->databaseConfiguration = $databaseConfiguration; - } - - public function getBaseUrl() - { - return $this->baseUrl; - } - - public function setBaseUrl($baseUrl) - { - $this->baseUrl = $baseUrl; - } - - public function getAdminUser() - { - return $this->adminUser; - } - - public function setAdminUser(array $adminUser) - { - $this->adminUser = $adminUser; - } - - public function getSettings() - { - return $this->settings; - } - - public function setSettings(array $settings) - { - $this->settings = $settings; - } - - public function setSetting($key, $value) - { - $this->settings[$key] = $value; - } - - public function isDebugMode(): bool - { - return $this->debug; - } - - public function setDebugMode(bool $debug = true) - { - $this->debug = $debug; - } -} diff --git a/src/Install/Console/FileDataProvider.php b/src/Install/Console/FileDataProvider.php index 7e4a00d0a8..09975b8619 100644 --- a/src/Install/Console/FileDataProvider.php +++ b/src/Install/Console/FileDataProvider.php @@ -17,7 +17,6 @@ class FileDataProvider implements DataProviderInterface { - protected $default; protected $debug = false; protected $baseUrl = null; protected $databaseConfiguration = []; @@ -26,9 +25,6 @@ class FileDataProvider implements DataProviderInterface public function __construct(InputInterface $input) { - // Get default configuration - $this->default = new DefaultsDataProvider(); - // Get configuration file path $configurationFile = $input->getOption('file'); @@ -57,17 +53,33 @@ public function __construct(InputInterface $input) public function getDatabaseConfiguration() { - return $this->databaseConfiguration + $this->default->getDatabaseConfiguration(); + return $this->databaseConfiguration + [ + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'flarum', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'port' => '3306', + 'strict' => false, + ]; } public function getBaseUrl() { - return (! is_null($this->baseUrl)) ? $this->baseUrl : $this->default->getBaseUrl(); + return $this->baseUrl ?? 'http://flarum.local'; } public function getAdminUser() { - return $this->adminUser + $this->default->getAdminUser(); + return $this->adminUser + [ + 'username' => 'admin', + 'password' => 'password', + 'password_confirmation' => 'password', + 'email' => 'admin@example.com', + ]; } public function getSettings() diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php index 246dbc0ced..7213e5ef23 100644 --- a/src/Install/Console/InstallCommand.php +++ b/src/Install/Console/InstallCommand.php @@ -53,12 +53,6 @@ protected function configure() $this ->setName('install') ->setDescription("Run Flarum's installation migration and seeds") - ->addOption( - 'defaults', - 'd', - InputOption::VALUE_NONE, - 'Create default settings and user' - ) ->addOption( 'file', 'f', @@ -95,9 +89,7 @@ protected function fire() protected function init() { - if ($this->input->getOption('defaults')) { - $this->dataSource = new DefaultsDataProvider(); - } elseif ($this->input->getOption('file')) { + if ($this->input->getOption('file')) { $this->dataSource = new FileDataProvider($this->input); } else { $this->dataSource = new UserDataProvider($this->input, $this->output, $this->getHelperSet()->get('question'));