Completed
Pull Request — master (#232)
by Ryan
17:41 queued 09:38
created

Install::fire()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 61
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 61
rs 9.5147
cc 1
eloc 37
nc 1
nop 3

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace Anomaly\Streams\Platform\Installer\Console;
2
3
use Anomaly\Streams\Platform\Addon\AddonManager;
4
use Anomaly\Streams\Platform\Application\Application;
5
use Anomaly\Streams\Platform\Application\Command\ReloadEnvironmentFile;
6
use Anomaly\Streams\Platform\Application\Command\WriteEnvironmentFile;
7
use Anomaly\Streams\Platform\Installer\Console\Command\ConfigureDatabase;
8
use Anomaly\Streams\Platform\Installer\Console\Command\ConfirmLicense;
9
use Anomaly\Streams\Platform\Installer\Console\Command\LoadApplicationInstallers;
10
use Anomaly\Streams\Platform\Installer\Console\Command\LoadCoreInstallers;
11
use Anomaly\Streams\Platform\Installer\Console\Command\LoadExtensionInstallers;
12
use Anomaly\Streams\Platform\Installer\Console\Command\LoadExtensionSeeders;
13
use Anomaly\Streams\Platform\Installer\Console\Command\LoadModuleInstallers;
14
use Anomaly\Streams\Platform\Installer\Console\Command\LoadModuleSeeders;
15
use Anomaly\Streams\Platform\Installer\Console\Command\LocateApplication;
16
use Anomaly\Streams\Platform\Installer\Console\Command\RunInstallers;
17
use Anomaly\Streams\Platform\Installer\Console\Command\SetAdminData;
18
use Anomaly\Streams\Platform\Installer\Console\Command\SetApplicationData;
19
use Anomaly\Streams\Platform\Installer\Console\Command\SetDatabaseData;
20
use Anomaly\Streams\Platform\Installer\Console\Command\SetDatabasePrefix;
21
use Anomaly\Streams\Platform\Installer\Console\Command\SetOtherData;
22
use Anomaly\Streams\Platform\Installer\Console\Command\SetStreamsData;
23
use Anomaly\Streams\Platform\Installer\Event\StreamsHasInstalled;
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\Config\Repository;
29
use Illuminate\Contracts\Console\Kernel;
30
use Illuminate\Contracts\Events\Dispatcher;
31
use Illuminate\Foundation\Bus\DispatchesJobs;
32
33
/**
34
 * Class Install
35
 *
36
 * @link          http://anomaly.is/streams-platform
37
 * @author        AnomalyLabs, Inc. <[email protected]>
38
 * @author        Ryan Thompson <[email protected]>
39
 * @package       Anomaly\Streams\Platform\Installer\Console
40
 */
41
class Install extends Command
42
{
43
44
    use DispatchesJobs;
45
46
    /**
47
     * The console command name.
48
     *
49
     * @var string
50
     */
51
    protected $name = 'install';
52
53
    /**
54
     * The console command description.
55
     *
56
     * @var string
57
     */
58
    protected $description = 'Install the Streams Platform.';
59
60
    /**
61
     * Execute the console command.
62
     */
63
    public function fire(Dispatcher $events, Application $application, AddonManager $manager)
0 ignored issues
show
Unused Code introduced by
The parameter $application is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65
        $this->dispatch(new ConfirmLicense($this));
66
67
        $data = new Collection();
68
69
        $this->dispatch(new SetStreamsData($data));
70
        $this->dispatch(new SetDatabaseData($data, $this));
71
        $this->dispatch(new SetApplicationData($data, $this));
72
        $this->dispatch(new SetAdminData($data, $this));
73
        $this->dispatch(new SetOtherData($data, $this));
74
75
        $this->dispatch(new WriteEnvironmentFile($data->all()));
76
        $this->dispatch(new ReloadEnvironmentFile());
77
78
        $this->dispatch(new ConfigureDatabase());
79
        $this->dispatch(new SetDatabasePrefix());
80
        $this->dispatch(new LocateApplication());
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
        $this->dispatch(new RunInstallers($installers, $this));
90
91
        $this->call('env:set', ['line' => 'INSTALLED=true']);
92
93
        $this->dispatch(new ReloadEnvironmentFile());
94
95
        $installers->add(
96
            new Installer(
97
                'streams::installer.running_migrations',
98
                function (Kernel $console) {
99
                    $console->call('migrate', ['--force' => true, '--no-addons' => true]);
100
                }
101
            )
102
        );
103
104
        $manager->register(); // Register all of our addons.
105
106
        $events->fire(new StreamsHasInstalled($installers));
107
108
        $this->info('Running post installation tasks.');
109
110
        $this->dispatch(new LoadModuleSeeders($installers));
111
        $this->dispatch(new LoadExtensionSeeders($installers));
112
113
        $installers->add(
114
            new Installer(
115
                'streams::installer.running_seeds',
116
                function (Kernel $console) {
117
                    $console->call('db:seed');
118
                }
119
            )
120
        );
121
122
        $this->dispatch(new RunInstallers($installers, $this));
123
    }
124
}
125