Completed
Push — development ( 7f669c...756641 )
by Torben
05:24 queued 14s
created

UtilityService::clearCacheForConfiguredUids()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
namespace DERHANSEN\SfEventMgt\Service;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Extbase\Service\CacheService;
18
19
/**
20
 * UtilityService
21
 *
22
 * @author Torben Hansen <[email protected]>
23
 */
24
class UtilityService
25
{
26
    /**
27
     * CacheService
28
     *
29
     * @var \TYPO3\CMS\Extbase\Service\CacheService
30
     * */
31
    protected $cacheService;
32
33
    /**
34
     * Settings Service
35
     *
36
     * @var \DERHANSEN\SfEventMgt\Service\SettingsService
37
     * */
38
    protected $settingsService;
39
40
    /**
41
     * DI for $cacheService
42
     *
43
     * @param CacheService $cacheService
44
     */
45
    public function injectCacheService(\TYPO3\CMS\Extbase\Service\CacheService $cacheService)
46
    {
47
        $this->cacheService = $cacheService;
48 2
    }
49
50 2
    /**
51 2
     * DI for $settingsService
52 1
     *
53 1
     * @param SettingsService $settingsService
54 2
     */
55
    public function injectSettingsService(\DERHANSEN\SfEventMgt\Service\SettingsService $settingsService)
56
    {
57
        $this->settingsService = $settingsService;
58
    }
59
60
    /**
61
     * Clears the cache of configured pages in TypoScript
62
     *
63
     * @param array $settings The settings
64
     *
65
     * @return void
66
     */
67
    public function clearCacheForConfiguredUids($settings)
68
    {
69
        $pidList = $this->settingsService->getClearCacheUids($settings);
70
        if (count($pidList) > 0) {
71
            $this->cacheService->clearPageCache($pidList);
72
        }
73
    }
74
}
75