1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\AppBundle\Command\Package; |
14
|
|
|
|
15
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Input\InputOption; |
18
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
19
|
|
|
use WellCommerce\Bundle\AppBundle\Entity\Package; |
20
|
|
|
use WellCommerce\Bundle\CoreBundle\Helper\Package\PackageHelperInterface; |
21
|
|
|
use WellCommerce\Bundle\CoreBundle\Helper\Process\ProcessHelperInterface; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Class AbstractCommand |
25
|
|
|
* |
26
|
|
|
* @author Adam Piotrowski <[email protected]> |
27
|
|
|
*/ |
28
|
|
|
abstract class AbstractPackageCommand extends ContainerAwareCommand |
29
|
|
|
{ |
30
|
|
|
protected $composerOperation = 'update'; |
31
|
|
|
|
32
|
|
|
protected function configure() |
33
|
|
|
{ |
34
|
|
|
$this->addOption('package', null, InputOption::VALUE_REQUIRED, 'Name of the package'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
38
|
|
|
{ |
39
|
|
|
putenv('COMPOSER_HOME=' . $this->getContainer()->get('kernel')->getRootDir() . '/.composer'); |
40
|
|
|
|
41
|
|
|
$package = $this->getPackage($input->getOption('package')); |
42
|
|
|
$arguments = $this->getCommandArguments($package); |
43
|
|
|
$process = $this->getProcessHelper()->createProcess($arguments); |
44
|
|
|
$process->start(); |
45
|
|
|
|
46
|
|
|
foreach ($process as $type => $data) { |
47
|
|
|
echo $data . "\n"; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
protected function getCommandArguments(Package $package): array |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
'composer.phar', |
55
|
|
|
$this->composerOperation, |
56
|
|
|
$package->getFullName(), |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function getPackage(string $name): Package |
61
|
|
|
{ |
62
|
|
|
return $this->getContainer()->get('package.repository')->findOneBy(['name' => $name]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function getProcessHelper(): ProcessHelperInterface |
66
|
|
|
{ |
67
|
|
|
return $this->getContainer()->get('process.helper'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function getPackageHelper(): PackageHelperInterface |
71
|
|
|
{ |
72
|
|
|
return $this->getContainer()->get('package.helper'); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|