Code Duplication    Length = 46-51 lines in 4 locations

src/Installer/Console/Command/LoadExtensionSeeders.php 1 location

@@ 16-61 (lines=46) @@
13
 * @author PyroCMS, Inc. <[email protected]>
14
 * @author Ryan Thompson <[email protected]>
15
 */
16
class LoadExtensionSeeders
17
{
18
19
    /**
20
     * The installer collection.
21
     *
22
     * @var InstallerCollection
23
     */
24
    protected $installers;
25
26
    /**
27
     * Create a new LoadExtensionSeeders instance.
28
     *
29
     * @param InstallerCollection $installers
30
     */
31
    public function __construct(InstallerCollection $installers)
32
    {
33
        $this->installers = $installers;
34
    }
35
36
    /**
37
     * Handle the command.
38
     *
39
     * @param ExtensionCollection $extensions
40
     */
41
    public function handle(ExtensionCollection $extensions)
42
    {
43
        /* @var Extension $extension */
44
        foreach ($extensions as $extension) {
45
            $this->installers->add(
46
                new Installer(
47
                    trans('streams::installer.seeding', ['seeding' => trans($extension->getName())]),
48
                    function (Kernel $console) use ($extension) {
49
                        $console->call(
50
                            'db:seed',
51
                            [
52
                                '--addon' => $extension->getNamespace(),
53
                                '--force' => true,
54
                            ]
55
                        );
56
                    }
57
                )
58
            );
59
        }
60
    }
61
}
62

src/Installer/Console/Command/LoadModuleSeeders.php 1 location

@@ 16-65 (lines=50) @@
13
 * @author PyroCMS, Inc. <[email protected]>
14
 * @author Ryan Thompson <[email protected]>
15
 */
16
class LoadModuleSeeders
17
{
18
19
    /**
20
     * The installer collection.
21
     *
22
     * @var InstallerCollection
23
     */
24
    protected $installers;
25
26
    /**
27
     * Create a new LoadModuleSeeders instance.
28
     *
29
     * @param InstallerCollection $installers
30
     */
31
    public function __construct(InstallerCollection $installers)
32
    {
33
        $this->installers = $installers;
34
    }
35
36
    /**
37
     * Handle the command.
38
     *
39
     * @param ModuleCollection $modules
40
     */
41
    public function handle(ModuleCollection $modules)
42
    {
43
        /* @var Module $module */
44
        foreach ($modules as $module) {
45
            if ($module->getNamespace() == 'anomaly.module.installer') {
46
                continue;
47
            }
48
49
            $this->installers->add(
50
                new Installer(
51
                    trans('streams::installer.seeding', ['seeding' => trans($module->getName())]),
52
                    function (Kernel $console) use ($module) {
53
                        $console->call(
54
                            'db:seed',
55
                            [
56
                                '--addon' => $module->getNamespace(),
57
                                '--force' => true,
58
                            ]
59
                        );
60
                    }
61
                )
62
            );
63
        }
64
    }
65
}
66

src/Installer/Console/Command/LoadExtensionInstallers.php 1 location

@@ 17-63 (lines=47) @@
14
 * @author PyroCMS, Inc. <[email protected]>
15
 * @author Ryan Thompson <[email protected]>
16
 */
17
class LoadExtensionInstallers
18
{
19
20
    /**
21
     * The installer collection.
22
     *
23
     * @var InstallerCollection
24
     */
25
    protected $installers;
26
27
    /**
28
     * Create a new LoadExtensionInstallers instance.
29
     *
30
     * @param InstallerCollection $installers
31
     */
32
    public function __construct(InstallerCollection $installers)
33
    {
34
        $this->installers = $installers;
35
    }
36
37
    /**
38
     * Handle the command.
39
     *
40
     * @param ExtensionCollection $extensions
41
     * @param Application         $application
42
     */
43
    public function handle(ExtensionCollection $extensions, Application $application)
44
    {
45
        /* @var Extension $extension */
46
        foreach ($extensions as $extension) {
47
            $this->installers->add(
48
                new Installer(
49
                    trans('streams::installer.installing', ['installing' => trans($extension->getName())]),
50
                    function (Kernel $console) use ($extension, $application) {
51
                        $console->call(
52
                            'extension:install',
53
                            [
54
                                'extension' => $extension->getNamespace(),
55
                                '--app'     => $application->getReference(),
56
                            ]
57
                        );
58
                    }
59
                )
60
            );
61
        }
62
    }
63
}
64

src/Installer/Console/Command/LoadModuleInstallers.php 1 location

@@ 17-67 (lines=51) @@
14
 * @author PyroCMS, Inc. <[email protected]>
15
 * @author Ryan Thompson <[email protected]>
16
 */
17
class LoadModuleInstallers
18
{
19
20
    /**
21
     * The installer collection.
22
     *
23
     * @var InstallerCollection
24
     */
25
    protected $installers;
26
27
    /**
28
     * Create a new LoadModuleInstallers instance.
29
     *
30
     * @param InstallerCollection $installers
31
     */
32
    public function __construct(InstallerCollection $installers)
33
    {
34
        $this->installers = $installers;
35
    }
36
37
    /**
38
     * Handle the command.
39
     *
40
     * @param ModuleCollection $modules
41
     * @param Application      $application
42
     */
43
    public function handle(ModuleCollection $modules, Application $application)
44
    {
45
        /* @var Module $module */
46
        foreach ($modules as $module) {
47
            if ($module->getNamespace() == 'anomaly.module.installer') {
48
                continue;
49
            }
50
51
            $this->installers->add(
52
                new Installer(
53
                    trans('streams::installer.installing', ['installing' => trans($module->getName())]),
54
                    function (Kernel $console) use ($module, $application) {
55
                        $console->call(
56
                            'module:install',
57
                            [
58
                                'module' => $module->getNamespace(),
59
                                '--app'  => $application->getReference(),
60
                            ]
61
                        );
62
                    }
63
                )
64
            );
65
        }
66
    }
67
}
68