CachesClearedEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 43
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getExampleProperties() 0 5 1
A run() 0 11 3
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C)
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\Domain\Event\TYPO3;
19
20
use CuyZ\Notiz\Core\Event\AbstractEvent;
21
use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties;
22
use TYPO3\CMS\Core\Utility\MathUtility;
23
24
/**
25
 * Event triggered when TYPO3 caches are cleared.
26
 */
27
class CachesClearedEvent extends AbstractEvent implements ProvidesExampleProperties
28
{
29
    /**
30
     * @label Event/TYPO3:cache_cleared.marker.cache_command
31
     * @marker
32
     *
33
     * @var string
34
     */
35
    protected $cacheCommand;
36
37
    /**
38
     * @label Event/TYPO3:cache_cleared.marker.page_uid
39
     * @marker
40
     *
41
     * @var int
42
     */
43
    protected $pageUid;
44
45
    /**
46
     * @param array $parameters
47
     */
48
    public function run(array $parameters)
49
    {
50
        $this->cacheCommand = $parameters['cacheCmd'];
51
52
        if (empty($this->cacheCommand)) {
53
            $this->cancelDispatch();
54
        }
55
56
        if (MathUtility::canBeInterpretedAsInteger($this->cacheCommand)) {
57
            $this->pageUid = (int)$this->cacheCommand;
58
            $this->cacheCommand = 'page';
59
        }
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getExampleProperties(): array
66
    {
67
        return [
68
            'cacheCommand' => 'page',
69
            'pageUid' => 42,
70
        ];
71
    }
72
}
73