/
WriteSettings.php
78 lines (66 loc) · 2 KB
/
WriteSettings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Install\Steps;
use Flarum\Foundation\Application;
use Flarum\Install\Step;
use Flarum\Settings\DatabaseSettingsRepository;
use Illuminate\Database\ConnectionInterface;
class WriteSettings implements Step
{
/**
* @var ConnectionInterface
*/
private $database;
/**
* @var array
*/
private $custom;
public function __construct(ConnectionInterface $database, array $custom)
{
$this->database = $database;
$this->custom = $custom;
}
public function getMessage()
{
return 'Writing default settings';
}
public function run()
{
$repo = new DatabaseSettingsRepository($this->database);
$repo->set('version', Application::VERSION);
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' => 'Enjoy your new forum! Hop over to discuss.flarum.org if you have any questions, or to join our community!',
'welcome_title' => 'Welcome to Flarum',
];
}
}