|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Gearman Bundle for Symfony2 |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
* |
|
9
|
|
|
* Feel free to edit as you please, and have fun. |
|
10
|
|
|
* |
|
11
|
|
|
* @author Marc Morera <[email protected]> |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Mmoreram\GearmanBundle\Command; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
|
|
19
|
|
|
use Mmoreram\GearmanBundle\Command\Abstracts\AbstractGearmanCommand; |
|
20
|
|
|
use Mmoreram\GearmanBundle\Service\GearmanCacheWrapper; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Clears all cache data |
|
24
|
|
|
* |
|
25
|
|
|
* @since 2.3.1 |
|
26
|
|
|
*/ |
|
27
|
|
|
class GearmanCacheClearCommand extends AbstractGearmanCommand |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @var GearmanCacheWrapper |
|
31
|
|
|
* |
|
32
|
|
|
* GearmanCacheWrapper |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $gearmanCacheWrapper; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Set the GearmanCacheWrapper instance |
|
38
|
|
|
* |
|
39
|
|
|
* @param GearmanCacheWrapper $gearmanCacheWrapper GearmanCacheWrapper |
|
40
|
|
|
* |
|
41
|
|
|
* @return GearmanCacheWarmupCommand self Object |
|
42
|
|
|
*/ |
|
43
|
2 |
|
public function setGearmanCacheWrapper(GearmanCacheWrapper $gearmanCacheWrapper) |
|
44
|
|
|
{ |
|
45
|
2 |
|
$this->gearmanCacheWrapper = $gearmanCacheWrapper; |
|
46
|
|
|
|
|
47
|
2 |
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Console Command configuration |
|
52
|
|
|
*/ |
|
53
|
2 |
|
protected function configure() |
|
54
|
|
|
{ |
|
55
|
|
|
$this |
|
56
|
2 |
|
->setName('gearman:cache:clear') |
|
57
|
2 |
|
->setAliases(array( |
|
58
|
2 |
|
'cache:gearman:clear' |
|
59
|
|
|
)) |
|
60
|
2 |
|
->setDescription('Clears gearman cache data on current environment'); |
|
61
|
2 |
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Executes the current command. |
|
65
|
|
|
* |
|
66
|
|
|
* @param InputInterface $input An InputInterface instance |
|
67
|
|
|
* @param OutputInterface $output An OutputInterface instance |
|
68
|
|
|
* |
|
69
|
|
|
* @return integer 0 if everything went fine, or an error code |
|
70
|
|
|
* |
|
71
|
|
|
* @throws \LogicException When this abstract class is not implemented |
|
72
|
|
|
*/ |
|
73
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
74
|
|
|
{ |
|
75
|
|
|
if ( |
|
76
|
2 |
|
!$input->getOption('quiet') |
|
77
|
|
|
) { |
|
78
|
|
|
$kernelEnvironment = $this |
|
79
|
1 |
|
->kernel |
|
80
|
1 |
|
->getEnvironment(); |
|
81
|
|
|
|
|
82
|
1 |
|
$output->writeln('Clearing the cache for the ' . $kernelEnvironment . ' environment'); |
|
83
|
|
|
} |
|
84
|
|
|
$this |
|
85
|
2 |
|
->gearmanCacheWrapper |
|
86
|
2 |
|
->clear(''); |
|
87
|
2 |
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|