1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.ec-cube.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\Repository\PluginRepository; |
17
|
|
|
use Eccube\Service\PluginService; |
18
|
|
|
use Symfony\Component\Console\Command\Command; |
19
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
20
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
21
|
|
|
|
22
|
|
|
trait PluginCommandTrait |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var PluginService |
26
|
|
|
*/ |
27
|
|
|
protected $pluginService; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var PluginRepository |
31
|
|
|
*/ |
32
|
|
|
protected $pluginRepository; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param PluginService $pluginService |
36
|
|
|
* @required |
37
|
|
|
*/ |
38
|
|
|
public function setPluginService(PluginService $pluginService) |
39
|
|
|
{ |
40
|
|
|
$this->pluginService = $pluginService; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param PluginRepository $pluginRepository |
45
|
|
|
* @required |
46
|
|
|
*/ |
47
|
|
|
public function setPluginRepository(PluginRepository $pluginRepository) |
48
|
|
|
{ |
49
|
|
|
$this->pluginRepository = $pluginRepository; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
protected function clearCache(SymfonyStyle $io) |
53
|
|
|
{ |
54
|
|
|
try { |
55
|
|
|
/* @var Command $command */ |
56
|
|
|
$command = $this->getApplication()->get('cache:clear'); |
|
|
|
|
57
|
|
|
$command->run(new ArrayInput([ |
58
|
|
|
'command' => 'cache:clear', |
59
|
|
|
'--no-warmup' => true, |
60
|
|
|
]), $io); |
61
|
|
|
} catch (\Exception $e) { |
62
|
|
|
$io->error($e->getMessage()); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.