Completed
Push — master ( d20415...295400 )
by Ryan
02:56
created

ConfigureStreams::handle()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 26
rs 8.439
cc 5
eloc 15
nc 4
nop 3
1
<?php namespace Anomaly\SettingsModule\Setting\Command;
2
3
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
4
use Illuminate\Contracts\Bus\SelfHandling;
5
use Illuminate\Contracts\Config\Repository;
6
use Illuminate\Contracts\Foundation\Application;
7
8
/**
9
 * Class ConfigureStreams
10
 *
11
 * @link          http://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 * @package       Anomaly\SettingsModule\Setting\Command
15
 */
16
class ConfigureStreams implements SelfHandling
17
{
18
19
    /**
20
     * Handle the command.
21
     *
22
     * @param SettingRepositoryInterface $settings
23
     * @param Application                $application
24
     * @param Repository                 $config
25
     */
26
    public function handle(SettingRepositoryInterface $settings, Application $application, Repository $config)
27
    {
28
        $config->set('app.debug', $settings->value('streams::debug', false));
29
        $config->set('app.timezone', $settings->value('streams::timezone', 'UTC'));
30
31
        $config->set('streams::locales.default', $settings->value('streams::default_locale', 'en'));
32
        $config->set('streams::locales.enabled', $settings->value('streams::enabled_locales', ['en']));
33
34
        $config->set('streams::themes.admin', $settings->value('streams::admin_theme', env('ADMIN_THEME')));
35
        $config->set('streams::themes.standard', $settings->value('streams::standard_theme', env('STANDARD_THEME')));
36
37
        $maintenance = $settings->value('streams::maintenance', false);
38
39
        if ($maintenance && !$application->isDownForMaintenance()) {
40
            touch(storage_path('framework/down'));
41
        }
42
43
        if (!$maintenance && $application->isDownForMaintenance()) {
44
            unlink(storage_path('framework/down'));
45
        }
46
47
        $config->set('streams::maintenance.auth', $settings->value('streams::basic_auth', false));
48
        $config->set('streams::maintenance.ip_whitelist', $settings->value('streams::ip_whitelist', []));
49
50
        $config->set('streams::ui.per_page', $settings->value('streams::per_page', 15));
51
    }
52
}
53