mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 18:12:59 +08:00
Move default settings to install step
The various installation "frontends" (such as GUI and console) can now provide custom overrides, if they want to.
This commit is contained in:
parent
f5a21584c2
commit
bc9e8f68f1
|
@ -37,25 +37,7 @@ class DefaultsDataProvider implements DataProviderInterface
|
|||
'email' => 'admin@example.com',
|
||||
];
|
||||
|
||||
protected $settings = [
|
||||
'allow_post_editing' => 'reply',
|
||||
'allow_renaming' => '10',
|
||||
'allow_sign_up' => '1',
|
||||
'custom_less' => '',
|
||||
'default_locale' => 'en',
|
||||
'default_route' => '/all',
|
||||
'extensions_enabled' => '[]',
|
||||
'forum_title' => 'Development Forum',
|
||||
'forum_description' => '',
|
||||
'mail_driver' => 'mail',
|
||||
'mail_from' => 'noreply@flarum.dev',
|
||||
'theme_colored_header' => '0',
|
||||
'theme_dark_mode' => '0',
|
||||
'theme_primary_color' => '#4D698E',
|
||||
'theme_secondary_color' => '#4D698E',
|
||||
'welcome_message' => 'This is beta software and you should not use it in production.',
|
||||
'welcome_title' => 'Welcome to Development Forum',
|
||||
];
|
||||
protected $settings = [];
|
||||
|
||||
public function getDatabaseConfiguration()
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ class FileDataProvider implements DataProviderInterface
|
|||
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->settings + $this->default->getSettings();
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
public function isDebugMode(): bool
|
||||
|
|
|
@ -77,22 +77,8 @@ class UserDataProvider implements DataProviderInterface
|
|||
$baseUrl = $this->baseUrl ?: 'http://localhost';
|
||||
|
||||
return [
|
||||
'allow_post_editing' => 'reply',
|
||||
'allow_renaming' => '10',
|
||||
'allow_sign_up' => '1',
|
||||
'custom_less' => '',
|
||||
'default_locale' => 'en',
|
||||
'default_route' => '/all',
|
||||
'extensions_enabled' => '[]',
|
||||
'forum_title' => $title,
|
||||
'forum_description' => '',
|
||||
'mail_driver' => 'mail',
|
||||
'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)),
|
||||
'theme_colored_header' => '0',
|
||||
'theme_dark_mode' => '0',
|
||||
'theme_primary_color' => '#4D698E',
|
||||
'theme_secondary_color' => '#4D698E',
|
||||
'welcome_message' => 'This is beta software and you should not use it in production.',
|
||||
'welcome_title' => 'Welcome to '.$title,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -80,22 +80,8 @@ class InstallController implements RequestHandlerInterface
|
|||
'email' => array_get($input, 'adminEmail'),
|
||||
])
|
||||
->settings([
|
||||
'allow_post_editing' => 'reply',
|
||||
'allow_renaming' => '10',
|
||||
'allow_sign_up' => '1',
|
||||
'custom_less' => '',
|
||||
'default_locale' => 'en',
|
||||
'default_route' => '/all',
|
||||
'extensions_enabled' => '[]',
|
||||
'forum_title' => array_get($input, 'forumTitle'),
|
||||
'forum_description' => '',
|
||||
'mail_driver' => 'mail',
|
||||
'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)),
|
||||
'theme_colored_header' => '0',
|
||||
'theme_dark_mode' => '0',
|
||||
'theme_primary_color' => '#4D698E',
|
||||
'theme_secondary_color' => '#4D698E',
|
||||
'welcome_message' => 'This is beta software and you should not use it in production.',
|
||||
'welcome_title' => 'Welcome to '.array_get($input, 'forumTitle'),
|
||||
])
|
||||
->build();
|
||||
|
|
|
@ -21,7 +21,7 @@ class Installation
|
|||
private $debug = false;
|
||||
private $dbConfig = [];
|
||||
private $baseUrl;
|
||||
private $defaultSettings = [];
|
||||
private $customSettings = [];
|
||||
private $adminUser = [];
|
||||
|
||||
public function __construct($basePath, $publicPath, $storagePath)
|
||||
|
@ -61,7 +61,7 @@ class Installation
|
|||
|
||||
public function settings($settings)
|
||||
{
|
||||
$this->defaultSettings = $settings;
|
||||
$this->customSettings = $settings;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class Installation
|
|||
});
|
||||
|
||||
$pipeline->pipe(function () {
|
||||
return new Steps\WriteSettings($this->tmp['db'], $this->defaultSettings);
|
||||
return new Steps\WriteSettings($this->tmp['db'], $this->customSettings);
|
||||
});
|
||||
|
||||
$pipeline->pipe(function () {
|
||||
|
|
|
@ -26,12 +26,12 @@ class WriteSettings implements Step
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $defaults;
|
||||
private $custom;
|
||||
|
||||
public function __construct(ConnectionInterface $database, array $defaults)
|
||||
public function __construct(ConnectionInterface $database, array $custom)
|
||||
{
|
||||
$this->database = $database;
|
||||
$this->defaults = $defaults;
|
||||
$this->custom = $custom;
|
||||
}
|
||||
|
||||
public function getMessage()
|
||||
|
@ -45,8 +45,36 @@ class WriteSettings implements Step
|
|||
|
||||
$repo->set('version', Application::VERSION);
|
||||
|
||||
foreach ($this->defaults as $key => $value) {
|
||||
foreach ($this->getSettings() as $key => $value) {
|
||||
$repo->set($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
private function getSettings()
|
||||
{
|
||||
return $this->custom + $this->getDefaults();
|
||||
}
|
||||
|
||||
private function getDefaults()
|
||||
{
|
||||
return [
|
||||
'allow_post_editing' => 'reply',
|
||||
'allow_renaming' => '10',
|
||||
'allow_sign_up' => '1',
|
||||
'custom_less' => '',
|
||||
'default_locale' => 'en',
|
||||
'default_route' => '/all',
|
||||
'extensions_enabled' => '[]',
|
||||
'forum_title' => 'A new Flarum forum',
|
||||
'forum_description' => '',
|
||||
'mail_driver' => 'mail',
|
||||
'mail_from' => 'noreply@localhost',
|
||||
'theme_colored_header' => '0',
|
||||
'theme_dark_mode' => '0',
|
||||
'theme_primary_color' => '#4D698E',
|
||||
'theme_secondary_color' => '#4D698E',
|
||||
'welcome_message' => 'This is beta software and you should not use it in production.',
|
||||
'welcome_title' => 'Welcome to Flarum',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,22 +69,8 @@ class DefaultInstallationTest extends TestCase
|
|||
private function getSettings()
|
||||
{
|
||||
return [
|
||||
'allow_post_editing' => 'reply',
|
||||
'allow_renaming' => '10',
|
||||
'allow_sign_up' => '1',
|
||||
'custom_less' => '',
|
||||
'default_locale' => 'en',
|
||||
'default_route' => '/all',
|
||||
'extensions_enabled' => '[]',
|
||||
'forum_title' => 'Development Forum',
|
||||
'forum_description' => '',
|
||||
'mail_driver' => 'log',
|
||||
'mail_from' => 'noreply@flarum.dev',
|
||||
'theme_colored_header' => '0',
|
||||
'theme_dark_mode' => '0',
|
||||
'theme_primary_color' => '#4D698E',
|
||||
'theme_secondary_color' => '#4D698E',
|
||||
'welcome_message' => 'This is beta software and you should not use it in production.',
|
||||
'welcome_title' => 'Welcome to Development Forum',
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user