|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PiouPiou\RibsAdminBundle\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
|
|
6
|
|
|
use PiouPiou\RibsAdminBundle\Entity\Module; |
|
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
|
8
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
|
|
|
|
|
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
|
|
11
|
|
|
use Symfony\Component\Process\Exception\ProcessFailedException; |
|
|
|
|
|
|
12
|
|
|
use Symfony\Component\Process\Process; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class ImportModuleCommand extends ContainerAwareCommand |
|
15
|
|
|
{ |
|
16
|
|
|
private $em; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* ImportModuleCommand constructor. |
|
20
|
|
|
* @param EntityManagerInterface $em |
|
21
|
|
|
* @param string|null $name |
|
22
|
|
|
*/ |
|
23
|
|
|
public function __construct(EntityManagerInterface $em, string $name = null) |
|
24
|
|
|
{ |
|
25
|
|
|
parent::__construct($name); |
|
26
|
|
|
$this->em = $em; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
|
|
$this |
|
32
|
|
|
->setName('ribsadmin:import-module') |
|
33
|
|
|
->setDescription('Import a module in ribs admin') |
|
34
|
|
|
->addArgument( |
|
35
|
|
|
'package-name', |
|
36
|
|
|
InputArgument::REQUIRED, |
|
37
|
|
|
'Name of composer package to import' |
|
38
|
|
|
) |
|
39
|
|
|
->addArgument( |
|
40
|
|
|
'module-name', |
|
41
|
|
|
InputArgument::REQUIRED, |
|
42
|
|
|
'Name of package to display in app' |
|
43
|
|
|
) |
|
44
|
|
|
; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
48
|
|
|
{ |
|
49
|
|
|
$pacakge_name = $input->getArgument('package-name'); |
|
50
|
|
|
$output->writeln("Start composer require " . $pacakge_name); |
|
51
|
|
|
|
|
52
|
|
|
$process = new Process("composer require " . $pacakge_name); |
|
53
|
|
|
$process->run(function ($type, $buffer) { |
|
54
|
|
|
echo $buffer; |
|
55
|
|
|
}); |
|
56
|
|
|
|
|
57
|
|
|
if (!$process->isSuccessful()) { |
|
58
|
|
|
throw new ProcessFailedException($process); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$output->writeln("End composer require " . $pacakge_name); |
|
62
|
|
|
$output->writeln("Start insertion of module in database " . $pacakge_name); |
|
63
|
|
|
|
|
64
|
|
|
$module = new Module(); |
|
65
|
|
|
$module->setPackageName($pacakge_name); |
|
66
|
|
|
$module->setTitle($input->getArgument('module-name')); |
|
67
|
|
|
$module->setActive(false); |
|
68
|
|
|
$module->setDisplayed(true); |
|
69
|
|
|
$this->em->persist($module); |
|
70
|
|
|
$this->em->flush(); |
|
71
|
|
|
|
|
72
|
|
|
$output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface"); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths