1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.lockon.co.jp/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Eccube\Command; |
15
|
|
|
|
16
|
|
|
use Eccube\Common\EccubeConfig; |
17
|
|
|
use Eccube\Entity\Plugin; |
18
|
|
|
use Symfony\Component\Console\Command\Command; |
19
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
20
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
21
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
22
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
23
|
|
|
|
24
|
|
View Code Duplication |
class PluginUpdateCommand extends Command |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
protected static $defaultName = 'eccube:plugin:update'; |
27
|
|
|
|
28
|
|
|
use PluginCommandTrait; |
29
|
|
|
|
30
|
|
|
private $pluginRealDir; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* PluginUpdateCommand constructor. |
34
|
|
|
* |
35
|
|
|
* @param EccubeConfig $eccubeConfig |
36
|
|
|
*/ |
37
|
|
|
public function __construct(EccubeConfig $eccubeConfig) |
38
|
|
|
{ |
39
|
|
|
parent::__construct(); |
40
|
|
|
$this->pluginRealDir = $eccubeConfig['plugin_realdir']; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function configure() |
44
|
|
|
{ |
45
|
|
|
$this |
46
|
|
|
->addArgument('code', InputArgument::REQUIRED, 'Plugin code') |
47
|
|
|
->setDescription('Execute plugin update process.'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
51
|
|
|
{ |
52
|
|
|
$io = new SymfonyStyle($input, $output); |
53
|
|
|
|
54
|
|
|
$code = $input->getArgument('code'); |
55
|
|
|
|
56
|
|
|
/** @var Plugin $Plugin */ |
57
|
|
|
$Plugin = $this->pluginRepository->findByCode($code); |
58
|
|
|
|
59
|
|
|
if (!$Plugin) { |
60
|
|
|
$io->error("No such plugin `${code}`."); |
61
|
|
|
return 1; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$config = $this->pluginService->readConfig($this->pluginRealDir.DIRECTORY_SEPARATOR.$Plugin->getCode()); |
65
|
|
|
$this->pluginService->updatePlugin($Plugin, $config); |
66
|
|
|
$this->clearCache($io); |
67
|
|
|
|
68
|
|
|
$io->success('Updated.'); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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.