Completed
Push — master ( 3ff6f8...d255a7 )
by Ryan
03:01
created

SettingsModuleSeeder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php namespace Anomaly\SettingsModule;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
use Anomaly\Streams\Platform\Application\Command\ReadEnvironmentFile;
5
use Anomaly\Streams\Platform\Application\Command\WriteEnvironmentFile;
6
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
7
use Illuminate\Foundation\Bus\DispatchesJobs;
8
9
/**
10
 * Class SettingsModuleSeeder
11
 *
12
 * @link          http://pyrocms.com/
13
 * @author        PyroCMS, Inc. <[email protected]>
14
 * @author        Ryan Thompson <[email protected]>
15
 * @package       Anomaly\SettingsModule
16
 */
17
class SettingsModuleSeeder extends Seeder
18
{
19
20
    use DispatchesJobs;
21
22
    /**
23
     * The settings repository.
24
     *
25
     * @var SettingRepositoryInterface
26
     */
27
    protected $settings;
28
29
    /**
30
     * Create a new SettingsModuleSeeder instance.
31
     *
32
     * @param SettingRepositoryInterface $settings
33
     */
34
    public function __construct(SettingRepositoryInterface $settings)
35
    {
36
        parent::__construct();
37
38
        $this->settings = $settings;
39
    }
40
41
    /**
42
     * Run the command.
43
     */
44
    public function run()
45
    {
46
        $data = $this->dispatch(new ReadEnvironmentFile());
47
48
        if ($timezone = array_pull($data, 'APP_TIMEZONE')) {
49
            $this->settings->create(
50
                [
51
                    'key'   => 'streams::timezone',
52
                    'value' => $timezone
53
                ]
54
            );
55
        }
56
57
        if ($locale = array_pull($data, 'DEFAULT_LOCALE')) {
58
            $this->settings->create(
59
                [
60
                    'key'   => 'streams::default_locale',
61
                    'value' => $locale
62
                ]
63
            );
64
        }
65
66
        $this->dispatch(new WriteEnvironmentFile($data));
67
    }
68
}
69