1
|
|
|
<?php namespace Anomaly\Streams\Platform\Installer\Console\Command; |
2
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Addon\Module\Module; |
4
|
|
|
use Anomaly\Streams\Platform\Addon\Module\ModuleCollection; |
5
|
|
|
use Anomaly\Streams\Platform\Application\Application; |
6
|
|
|
use Anomaly\Streams\Platform\Console\Kernel; |
7
|
|
|
use Anomaly\Streams\Platform\Installer\Installer; |
8
|
|
|
use Anomaly\Streams\Platform\Installer\InstallerCollection; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class LoadModuleInstallers |
12
|
|
|
* |
13
|
|
|
* @link http://pyrocms.com/ |
14
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
15
|
|
|
* @author Ryan Thompson <[email protected]> |
16
|
|
|
*/ |
17
|
|
View Code Duplication |
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
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.