mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 14:27:30 +08:00
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:
parent
021aafd226
commit
24c91e49bc
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@ use Symfony\Component\Yaml\Yaml;
|
|||
|
||||
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 @@ class FileDataProvider implements DataProviderInterface
|
|||
|
||||
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()
|
||||
|
|
|
@ -53,12 +53,6 @@ class InstallCommand extends AbstractCommand
|
|||
$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 @@ class InstallCommand extends AbstractCommand
|
|||
|
||||
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'));
|
||||
|
|
Loading…
Reference in New Issue
Block a user