12dd340011c2e7a7e38864186e77b67a139ea227
[yaffs-website] / vendor / drupal / console / src / Command / Cache / TagInvalidateCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Cache\TagInvalidateCommand.
6  */
7
8 namespace Drupal\Console\Command\Cache;
9
10 use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
11 use Drupal\Console\Core\Command\Command;
12 use Symfony\Component\Console\Input\InputArgument;
13 use Symfony\Component\Console\Input\InputInterface;
14 use Symfony\Component\Console\Output\OutputInterface;
15
16 class TagInvalidateCommand extends Command
17 {
18     /**
19      * @var CacheTagsInvalidatorInterface
20      */
21     protected $invalidator;
22
23     /**
24      * TagInvalidateCommand constructor.
25      *
26      * @param CacheTagsInvalidatorInterface $invalidator
27      */
28     public function __construct(CacheTagsInvalidatorInterface $invalidator)
29     {
30         parent::__construct();
31         $this->invalidator = $invalidator;
32     }
33
34     /**
35      * {@inheritdoc}
36      */
37     protected function configure()
38     {
39         $this
40             ->setName('cache:tag:invalidate')
41             ->setDescription($this->trans('commands.cache.tag.invalidate.description'))
42             ->addArgument(
43                 'tag',
44                 InputArgument::REQUIRED | InputArgument::IS_ARRAY,
45                 $this->trans('commands.cache.tag.invalidate.options.tag')
46             )
47             ->setAliases(['cti']);
48     }
49
50     /**
51      * {@inheritdoc}
52      */
53     protected function execute(InputInterface $input, OutputInterface $output)
54     {
55         $tags = $input->getArgument('tag');
56
57         $this->getIo()->comment(
58             sprintf(
59                 $this->trans('commands.cache.tag.invalidate.messages.start'),
60                 implode(', ', $tags)
61             )
62         );
63
64         $this->invalidator->invalidateTags($tags);
65         $this->getIo()->success($this->trans('commands.cache.tag.invalidate.messages.completed'));
66     }
67 }