Completed
Push — master ( 0e9bc5...7ef25f )
by Ryan
15:00
created

Install::getOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Anomaly\Streams\Platform\Installer\Console;
2
3
use Anomaly\Streams\Platform\Addon\AddonManager;
4
use Anomaly\Streams\Platform\Application\Command\ReloadEnvironmentFile;
5
use Anomaly\Streams\Platform\Application\Command\WriteEnvironmentFile;
6
use Anomaly\Streams\Platform\Installer\Console\Command\ConfigureDatabase;
7
use Anomaly\Streams\Platform\Installer\Console\Command\ConfirmLicense;
8
use Anomaly\Streams\Platform\Installer\Console\Command\CreateEntrySearchIndexes;
9
use Anomaly\Streams\Platform\Installer\Console\Command\LoadApplicationInstallers;
10
use Anomaly\Streams\Platform\Installer\Console\Command\LoadBaseMigrations;
11
use Anomaly\Streams\Platform\Installer\Console\Command\LoadBaseSeeders;
12
use Anomaly\Streams\Platform\Installer\Console\Command\LoadCoreInstallers;
13
use Anomaly\Streams\Platform\Installer\Console\Command\LoadExtensionInstallers;
14
use Anomaly\Streams\Platform\Installer\Console\Command\LoadExtensionSeeders;
15
use Anomaly\Streams\Platform\Installer\Console\Command\LoadModuleInstallers;
16
use Anomaly\Streams\Platform\Installer\Console\Command\LoadModuleSeeders;
17
use Anomaly\Streams\Platform\Installer\Console\Command\RunInstallers;
18
use Anomaly\Streams\Platform\Installer\Console\Command\SetAdminData;
19
use Anomaly\Streams\Platform\Installer\Console\Command\SetApplicationData;
20
use Anomaly\Streams\Platform\Installer\Console\Command\SetDatabaseData;
21
use Anomaly\Streams\Platform\Installer\Console\Command\SetDatabasePrefix;
22
use Anomaly\Streams\Platform\Installer\Console\Command\SetOtherData;
23
use Anomaly\Streams\Platform\Installer\Console\Command\SetStreamsData;
24
use Anomaly\Streams\Platform\Installer\Installer;
25
use Anomaly\Streams\Platform\Installer\InstallerCollection;
26
use Anomaly\Streams\Platform\Support\Collection;
27
use Illuminate\Console\Command;
28
use Illuminate\Contracts\Events\Dispatcher;
29
use Illuminate\Foundation\Bus\DispatchesJobs;
30
use Symfony\Component\Console\Input\InputOption;
31
32
/**
33
 * Class Install
34
 *
35
 * @link   http://pyrocms.com/
36
 * @author PyroCMS, Inc. <[email protected]>
37
 * @author Ryan Thompson <[email protected]>
38
 */
39
class Install extends Command
40
{
41
42
    use DispatchesJobs;
43
44
    /**
45
     * The console command name.
46
     *
47
     * @var string
48
     */
49
    protected $name = 'install';
50
51
    /**
52
     * The console command description.
53
     *
54
     * @var string
55
     */
56
    protected $description = 'Install the Streams Platform.';
57
58
    /**
59
     * Execute the console command.
60
     */
61
    public function fire(Dispatcher $events, AddonManager $manager)
62
    {
63
        $data = new Collection();
64
65
        if (!$this->option('ready')) {
66
67
            $this->dispatch(new ConfirmLicense($this));
68
            $this->dispatch(new SetStreamsData($data));
69
            $this->dispatch(new SetDatabaseData($data, $this));
70
            $this->dispatch(new SetApplicationData($data, $this));
71
            $this->dispatch(new SetAdminData($data, $this));
72
            $this->dispatch(new SetOtherData($data, $this));
73
74
            $this->dispatch(new WriteEnvironmentFile($data->all()));
75
        }
76
77
        $this->dispatch(new ReloadEnvironmentFile());
78
79
        $this->dispatch(new ConfigureDatabase());
80
        $this->dispatch(new SetDatabasePrefix());
81
82
        $installers = new InstallerCollection();
83
84
        $this->dispatch(new LoadCoreInstallers($installers));
85
        $this->dispatch(new LoadApplicationInstallers($installers));
86
        $this->dispatch(new LoadModuleInstallers($installers));
87
        $this->dispatch(new LoadExtensionInstallers($installers));
88
89
        $installers->add(
90
            new Installer(
91
                'streams::installer.reloading_application',
92
                function () use ($manager, $events) {
93
94
                    $this->call('env:set', ['line' => 'INSTALLED=true']);
95
96
                    $this->dispatch(new ReloadEnvironmentFile());
97
                    $this->dispatch(new CreateEntrySearchIndexes());
98
99
                    $manager->register(); // Register all of our addons.
100
                }
101
            )
102
        );
103
104
        $this->dispatch(new LoadBaseMigrations($installers));
105
        $this->dispatch(new LoadBaseSeeders($installers));
106
107
        $this->dispatch(new LoadModuleSeeders($installers));
108
        $this->dispatch(new LoadExtensionSeeders($installers));
109
110
        $this->dispatch(new RunInstallers($installers, $this));
111
    }
112
113
    /**
114
     * Get the console command options.
115
     *
116
     * @return array
117
     */
118
    protected function getOptions()
119
    {
120
        return [
121
            ['ready', null, InputOption::VALUE_NONE, 'Indicates that the installer should use an existing .env file.'],
122
        ];
123
    }
124
}
125