Passed
Branch main (a47c5a)
by AOEPeople
15:53 queued 02:59
created

clearAllCaches()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
/***************************************************************
4
 *  Copyright notice
5
 *
6
 *  (c) 2016 AOE GmbH <[email protected]>
7
 *
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
/**
28
 * @package FeatureFlag
29
 * @subpackage System_Typo3
30
 */
31
class Tx_FeatureFlag_System_Typo3_CacheManager
32
{
33
    /**
34
     * @var \TYPO3\CMS\Extbase\Object\ObjectManager
35
     */
36
    private $objectManager;
37
38
    /**
39
     * Tx_FeatureFlag_System_Typo3_Cache constructor.
40
     * @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager
41
     */
42
    public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager)
43
    {
44
        $this->objectManager = $objectManager;
45
    }
46
47
    /**
48
     * Clear all caches. Therefor it is necessary to login a BE_USER. You have to prevent
49
     * this function to run on live systems!!!
50
     */
51
    public function clearAllCaches()
52
    {
53
        /** @var TYPO3\CMS\Core\DataHandling\DataHandler $tce */
54
        $tce = $this->objectManager->get(TYPO3\CMS\Core\DataHandling\DataHandler::class);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Extbase\Object\ObjectManager::get() has been deprecated: since TYPO3 10.4, will be removed in version 12.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

54
        $tce = /** @scrutinizer ignore-deprecated */ $this->objectManager->get(TYPO3\CMS\Core\DataHandling\DataHandler::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
55
        $tce->start(array(), array());
56
        $tce->admin = 1;
0 ignored issues
show
Documentation Bug introduced by
The property $admin was declared of type boolean, but 1 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
57
        $tce->clear_cacheCmd('all');
58
    }
59
}