PurgeUrlCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
rs 9.7998
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * File: PurgeUrlCommand.php
7
 *
8
 * @author Maciej Sławik <[email protected]>
9
 * @copyright Copyright (C) 2019 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\VarnishWarmer\Console\Command;
13
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Input\InputOption;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Class PurgeUrlCommand
21
 * @package LizardMedia\VarnishWarmer\Console\Command
22
 */
23
class PurgeUrlCommand extends AbstractPurgeCommand
24
{
25
    /**
26
     * @var string
27
     */
28
    public const CLI_COMMAND = 'lm-varnish:cache-refresh-url';
29
30
    /**
31
     * @var string
32
     */
33
    private const URL_ARGUMENT = 'url';
34
35
    /**
36
     * @return void
37
     */
38
    protected function configure(): void
39
    {
40
        $this->setName(self::CLI_COMMAND)
41
            ->setDescription('Clear varnish cache (make PURGE) and re-generate URL')
42
            ->addArgument(
43
                self::URL_ARGUMENT,
44
                InputArgument::REQUIRED,
45
                'Type a URL to PURGE and re-generate'
46
            )->addOption(
47
                self::STORE_VIEW_ID,
48
                null,
49
                InputOption::VALUE_OPTIONAL
50
            );
51
    }
52
53
    /**
54
     * @param InputInterface $input
55
     * @param OutputInterface $output
56
     * @return void
57
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
58
     */
59
    protected function execute(InputInterface $input, OutputInterface $output): void
60
    {
61
        $url = $input->getArgument(self::URL_ARGUMENT);
62
        $this->passStoreViewIfSet($input);
63
        $this->varnishActionManager->purgeAndRegenerateUrl($url);
64
    }
65
}
66