1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOSHttpCacheBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FOS\HttpCacheBundle\Command; |
13
|
|
|
|
14
|
|
|
use FOS\HttpCacheBundle\CacheManager; |
15
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* A command to trigger cache invalidation by tag from the command line. |
22
|
|
|
* |
23
|
|
|
* @author David Buchmann <[email protected]> |
24
|
|
|
*/ |
25
|
|
View Code Duplication |
class InvalidateTagCommand extends ContainerAwareCommand |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var CacheManager |
29
|
|
|
*/ |
30
|
|
|
private $cacheManager; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
private $commandName; |
|
|
|
|
36
|
|
|
|
37
|
10 |
|
public function __construct(CacheManager $cacheManager) |
38
|
|
|
{ |
39
|
10 |
|
$this->cacheManager = $cacheManager; |
40
|
10 |
|
parent::__construct(); |
41
|
10 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
10 |
|
protected function configure() |
47
|
|
|
{ |
48
|
|
|
$this |
49
|
10 |
|
->setName('fos:httpcache:invalidate:tag') |
50
|
10 |
|
->setDescription('Invalidate cached content matching the specified tags on all configured caching proxies') |
51
|
10 |
|
->addArgument( |
52
|
10 |
|
'tags', |
53
|
10 |
|
InputArgument::IS_ARRAY | InputArgument::REQUIRED, |
54
|
10 |
|
'Tags in the response tags header to invalidate' |
55
|
|
|
) |
56
|
10 |
|
->setHelp(<<<'EOF' |
57
|
|
|
The <info>%command.name%</info> command invalidates all cached content matching the specified tags on the configured caching proxies. |
58
|
|
|
|
59
|
|
|
Example: |
60
|
|
|
|
61
|
10 |
|
<info>php %command.full_name% my-tag other-tag </info> |
62
|
|
|
EOF |
63
|
|
|
) |
64
|
|
|
; |
65
|
10 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* {@inheritdoc} |
69
|
|
|
*/ |
70
|
3 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
71
|
|
|
{ |
72
|
3 |
|
$tags = $input->getArgument('tags'); |
73
|
|
|
|
74
|
3 |
|
$this->cacheManager->invalidateTags($tags); |
75
|
3 |
|
} |
76
|
|
|
} |
77
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.