mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 06:29:45 +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',
|
'email' => 'admin@example.com',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $settings = [
|
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',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function getDatabaseConfiguration()
|
public function getDatabaseConfiguration()
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,7 +72,7 @@ class FileDataProvider implements DataProviderInterface
|
||||||
|
|
||||||
public function getSettings()
|
public function getSettings()
|
||||||
{
|
{
|
||||||
return $this->settings + $this->default->getSettings();
|
return $this->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isDebugMode(): bool
|
public function isDebugMode(): bool
|
||||||
|
|
|
@ -77,22 +77,8 @@ class UserDataProvider implements DataProviderInterface
|
||||||
$baseUrl = $this->baseUrl ?: 'http://localhost';
|
$baseUrl = $this->baseUrl ?: 'http://localhost';
|
||||||
|
|
||||||
return [
|
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_title' => $title,
|
||||||
'forum_description' => '',
|
|
||||||
'mail_driver' => 'mail',
|
|
||||||
'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)),
|
'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,
|
'welcome_title' => 'Welcome to '.$title,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,22 +80,8 @@ class InstallController implements RequestHandlerInterface
|
||||||
'email' => array_get($input, 'adminEmail'),
|
'email' => array_get($input, 'adminEmail'),
|
||||||
])
|
])
|
||||||
->settings([
|
->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_title' => array_get($input, 'forumTitle'),
|
||||||
'forum_description' => '',
|
|
||||||
'mail_driver' => 'mail',
|
|
||||||
'mail_from' => 'noreply@'.preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)),
|
'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'),
|
'welcome_title' => 'Welcome to '.array_get($input, 'forumTitle'),
|
||||||
])
|
])
|
||||||
->build();
|
->build();
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Installation
|
||||||
private $debug = false;
|
private $debug = false;
|
||||||
private $dbConfig = [];
|
private $dbConfig = [];
|
||||||
private $baseUrl;
|
private $baseUrl;
|
||||||
private $defaultSettings = [];
|
private $customSettings = [];
|
||||||
private $adminUser = [];
|
private $adminUser = [];
|
||||||
|
|
||||||
public function __construct($basePath, $publicPath, $storagePath)
|
public function __construct($basePath, $publicPath, $storagePath)
|
||||||
|
@ -61,7 +61,7 @@ class Installation
|
||||||
|
|
||||||
public function settings($settings)
|
public function settings($settings)
|
||||||
{
|
{
|
||||||
$this->defaultSettings = $settings;
|
$this->customSettings = $settings;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ class Installation
|
||||||
});
|
});
|
||||||
|
|
||||||
$pipeline->pipe(function () {
|
$pipeline->pipe(function () {
|
||||||
return new Steps\WriteSettings($this->tmp['db'], $this->defaultSettings);
|
return new Steps\WriteSettings($this->tmp['db'], $this->customSettings);
|
||||||
});
|
});
|
||||||
|
|
||||||
$pipeline->pipe(function () {
|
$pipeline->pipe(function () {
|
||||||
|
|
|
@ -26,12 +26,12 @@ class WriteSettings implements Step
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $defaults;
|
private $custom;
|
||||||
|
|
||||||
public function __construct(ConnectionInterface $database, array $defaults)
|
public function __construct(ConnectionInterface $database, array $custom)
|
||||||
{
|
{
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
$this->defaults = $defaults;
|
$this->custom = $custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMessage()
|
public function getMessage()
|
||||||
|
@ -45,8 +45,36 @@ class WriteSettings implements Step
|
||||||
|
|
||||||
$repo->set('version', Application::VERSION);
|
$repo->set('version', Application::VERSION);
|
||||||
|
|
||||||
foreach ($this->defaults as $key => $value) {
|
foreach ($this->getSettings() as $key => $value) {
|
||||||
$repo->set($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()
|
private function getSettings()
|
||||||
{
|
{
|
||||||
return [
|
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_title' => 'Development Forum',
|
||||||
'forum_description' => '',
|
|
||||||
'mail_driver' => 'log',
|
'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',
|
'welcome_title' => 'Welcome to Development Forum',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user