Skip to content

Commit

Permalink
Get rid of DefaultsDataProvider
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
franzliedke committed Jan 31, 2019
1 parent 4585f03 commit 44c9109
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 112 deletions.
96 changes: 0 additions & 96 deletions src/Install/Console/DefaultsDataProvider.php

This file was deleted.

26 changes: 19 additions & 7 deletions src/Install/Console/FileDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

class FileDataProvider implements DataProviderInterface
{
protected $default;
protected $debug = false;
protected $baseUrl = null;
protected $databaseConfiguration = [];
Expand All @@ -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');

Expand Down Expand Up @@ -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()
Expand Down
10 changes: 1 addition & 9 deletions src/Install/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit 44c9109

Please sign in to comment.