CacheClearallCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * BEdita, API-first content management framework
6
 * Copyright 2020 ChannelWeb Srl, Chialab Srl
7
 *
8
 * This file is part of BEdita: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published
10
 * by the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
14
 */
15
namespace BEdita\WebTools\Command;
16
17
use Cake\Command\CacheClearallCommand as BaseCommand;
18
use Cake\Console\Arguments;
19
use Cake\Console\ConsoleIo;
20
21
/**
22
 * Extend `CacheClearallCommand` to remove Twig compiled files.
23
 */
24
class CacheClearallCommand extends BaseCommand
25
{
26
    /**
27
     * {@inheritDoc}
28
     *
29
     * Add `twig` compiled files removal step.
30
     */
31
    public function execute(Arguments $args, ConsoleIo $io): ?int
32
    {
33
        $path = CACHE . 'twig_view';
34
        if (!file_exists($path)) {
35
            $io->out("<warning>Twig cache path not found: {$path}</warning>");
36
37
            return parent::execute($args, $io);
38
        }
39
        unlink($path);
40
        $io->out('<success>Cleared twig cache</success>');
41
42
        return parent::execute($args, $io);
43
    }
44
}
45