Completed
Push — develop ( ff69a2...5c149c )
by Carsten
25:49 queued 22:46
created

ClearCacheController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Yawik project.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core\Controller\Console;
11
12
use Core\Service\ClearCacheService;
13
use Interop\Container\ContainerInterface;
14
use Zend\Mvc\Console\Controller\AbstractConsoleController;
15
16
/**
17
 * Clean Cache
18
 *
19
 * @package Core\Controller\Console
20
 * @author Anthonius Munthi <[email protected]>
21
 * @since 0.32
22
 */
23
class ClearCacheController extends AbstractConsoleController
24
{
25
    /**
26
     * @var ClearCacheService
27
     */
28
    private $cache;
29
30
    /**
31
     * CacheWarmupController constructor.
32
     * @param ClearCacheService $cache
33
     */
34
    public function __construct(ClearCacheService $cache)
35
    {
36
        $this->cache = $cache;
37
    }
38
39
    /**
40
     * @param ContainerInterface $container
41
     * @return ClearCacheController
42
     */
43
    public static function factory(ContainerInterface $container)
44
    {
45
        $cache = $container->get(ClearCacheService::class);
46
47
        return new static($cache);
48
    }
49
50
    /**
51
     * Clear cache
52
     * @return void|\Zend\View\Model\ViewModel
53
     */
54
    public function indexAction()
55
    {
56
        $console = $this->getConsole();
57
        $console->writeLine('Cleaning up all cache files.');
58
        $this->cache->clearCache();
59
    }
60
}
61