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\Installer\Installer; |
6
|
|
|
use Anomaly\Streams\Platform\Installer\InstallerCollection; |
7
|
|
|
use App\Console\Kernel; |
8
|
|
|
use Illuminate\Contracts\Bus\SelfHandling; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class LoadModuleSeeders |
12
|
|
|
* |
13
|
|
|
* @link http://anomaly.is/streams-platform |
14
|
|
|
* @author AnomalyLabs, Inc. <[email protected]> |
15
|
|
|
* @author Ryan Thompson <[email protected]> |
16
|
|
|
* @package Anomaly\Streams\Platform\Installer\Console\Command |
17
|
|
|
*/ |
18
|
|
View Code Duplication |
class LoadModuleSeeders implements SelfHandling |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The installer collection. |
23
|
|
|
* |
24
|
|
|
* @var InstallerCollection |
25
|
|
|
*/ |
26
|
|
|
protected $installers; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Create a new LoadModuleSeeders instance. |
30
|
|
|
* |
31
|
|
|
* @param InstallerCollection $installers |
32
|
|
|
*/ |
33
|
|
|
public function __construct(InstallerCollection $installers) |
34
|
|
|
{ |
35
|
|
|
$this->installers = $installers; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Handle the command. |
40
|
|
|
* |
41
|
|
|
* @param ModuleCollection $modules |
42
|
|
|
*/ |
43
|
|
|
public function handle(ModuleCollection $modules) |
44
|
|
|
{ |
45
|
|
|
/* @var Module $module */ |
46
|
|
|
foreach ($modules as $module) { |
47
|
|
|
|
48
|
|
|
if ($module->getNamespace() == 'anomaly.module.installer') { |
49
|
|
|
continue; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$this->installers->add( |
53
|
|
|
new Installer( |
54
|
|
|
trans('streams::installer.seeding', ['seeding' => trans($module->getName())]), |
55
|
|
|
function (Kernel $console) use ($module) { |
56
|
|
|
$console->call( |
57
|
|
|
'db:seed', |
58
|
|
|
[ |
59
|
|
|
'--addon' => $module->getNamespace(), |
60
|
|
|
'--force' => true |
61
|
|
|
] |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
) |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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.