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\Component\Console\Input\InputArgument; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* A command to trigger cache invalidation by tag from the command line. |
21
|
|
|
* |
22
|
|
|
* @author David Buchmann <[email protected]> |
23
|
|
|
*/ |
24
|
|
View Code Duplication |
class InvalidateTagCommand extends BaseInvalidateCommand |
25
|
|
|
{ |
26
|
|
|
protected static $defaultName = 'fos:httpcache:invalidate:tag'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* If no cache manager is specified explicitly, fos_http_cache.cache_manager |
30
|
|
|
* is automatically loaded. |
31
|
|
|
* |
32
|
|
|
* @param CacheManager|null $cacheManager The cache manager to talk to |
33
|
|
|
*/ |
34
|
4 |
|
public function __construct(CacheManager $cacheManager = null, $commandName = 'fos:httpcache:invalidate:tag') |
|
|
|
|
35
|
|
|
{ |
36
|
4 |
|
if (2 <= func_num_args()) { |
37
|
|
|
@trigger_error('Passing a command name in the constructor is deprecated and will be removed in version 3', E_USER_DEPRECATED); |
38
|
|
|
static::$defaultName = func_get_arg(1); |
39
|
|
|
} |
40
|
4 |
|
parent::__construct($cacheManager); |
41
|
4 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
4 |
|
protected function configure() |
47
|
|
|
{ |
48
|
|
|
$this |
49
|
4 |
|
->setDescription('Invalidate cached content matching the specified tags on all configured caching proxies') |
50
|
4 |
|
->addArgument( |
51
|
4 |
|
'tags', |
52
|
4 |
|
InputArgument::IS_ARRAY | InputArgument::REQUIRED, |
53
|
4 |
|
'Tags in the response tags header to invalidate' |
54
|
|
|
) |
55
|
4 |
|
->setHelp(<<<'EOF' |
56
|
4 |
|
The <info>%command.name%</info> command invalidates all cached content matching the specified tags on the configured caching proxies. |
57
|
|
|
|
58
|
|
|
Example: |
59
|
|
|
|
60
|
|
|
<info>php %command.full_name% my-tag other-tag </info> |
61
|
|
|
EOF |
62
|
|
|
) |
63
|
|
|
; |
64
|
4 |
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
*/ |
69
|
2 |
|
protected function execute(InputInterface $input, OutputInterface $output): int |
70
|
|
|
{ |
71
|
2 |
|
$tags = $input->getArgument('tags'); |
72
|
|
|
|
73
|
2 |
|
$this->getCacheManager()->invalidateTags($tags); |
74
|
|
|
|
75
|
2 |
|
return 0; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.