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.
This commit is contained in:
Franz Liedke 2019-01-22 22:03:47 +01:00
parent 021aafd226
commit 24c91e49bc
3 changed files with 20 additions and 112 deletions

View File

@ -1,96 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* 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;
}
}

View File

@ -17,7 +17,6 @@ use Symfony\Component\Yaml\Yaml;
class FileDataProvider implements DataProviderInterface class FileDataProvider implements DataProviderInterface
{ {
protected $default;
protected $debug = false; protected $debug = false;
protected $baseUrl = null; protected $baseUrl = null;
protected $databaseConfiguration = []; protected $databaseConfiguration = [];
@ -26,9 +25,6 @@ class FileDataProvider implements DataProviderInterface
public function __construct(InputInterface $input) public function __construct(InputInterface $input)
{ {
// Get default configuration
$this->default = new DefaultsDataProvider();
// Get configuration file path // Get configuration file path
$configurationFile = $input->getOption('file'); $configurationFile = $input->getOption('file');
@ -57,17 +53,33 @@ class FileDataProvider implements DataProviderInterface
public function getDatabaseConfiguration() 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() public function getBaseUrl()
{ {
return (! is_null($this->baseUrl)) ? $this->baseUrl : $this->default->getBaseUrl(); return $this->baseUrl ?? 'http://flarum.local';
} }
public function getAdminUser() 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() public function getSettings()

View File

@ -53,12 +53,6 @@ class InstallCommand extends AbstractCommand
$this $this
->setName('install') ->setName('install')
->setDescription("Run Flarum's installation migration and seeds") ->setDescription("Run Flarum's installation migration and seeds")
->addOption(
'defaults',
'd',
InputOption::VALUE_NONE,
'Create default settings and user'
)
->addOption( ->addOption(
'file', 'file',
'f', 'f',
@ -95,9 +89,7 @@ class InstallCommand extends AbstractCommand
protected function init() protected function init()
{ {
if ($this->input->getOption('defaults')) { if ($this->input->getOption('file')) {
$this->dataSource = new DefaultsDataProvider();
} elseif ($this->input->getOption('file')) {
$this->dataSource = new FileDataProvider($this->input); $this->dataSource = new FileDataProvider($this->input);
} else { } else {
$this->dataSource = new UserDataProvider($this->input, $this->output, $this->getHelperSet()->get('question')); $this->dataSource = new UserDataProvider($this->input, $this->output, $this->getHelperSet()->get('question'));