1
|
|
|
<?php |
2
|
|
|
namespace Aoe\Varnish\Controller; |
3
|
|
|
|
4
|
|
|
use Aoe\Varnish\Domain\Model\Tag\PageTag; |
5
|
|
|
use Aoe\Varnish\Domain\Model\Tag\Tag; |
6
|
|
|
use Aoe\Varnish\System\Varnish; |
7
|
|
|
use TYPO3\CMS\Core\Messaging\AbstractMessage; |
8
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
9
|
|
|
|
10
|
|
|
class BanController extends ActionController |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Varnish |
14
|
|
|
*/ |
15
|
|
|
private $varnish; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param Varnish $varnish |
19
|
|
|
*/ |
20
|
|
|
public function __construct(Varnish $varnish) |
21
|
|
|
{ |
22
|
|
|
$this->varnish = $varnish; |
23
|
|
|
parent::__construct(); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function indexAction() |
27
|
|
|
{ |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function banTypo3PagesAction() |
31
|
|
|
{ |
32
|
|
|
$results = $this->varnish |
33
|
|
|
->banByTag(new PageTag('typo3_pages')) |
|
|
|
|
34
|
|
|
->shutdown(); |
35
|
|
|
|
36
|
|
|
foreach ($results as $result) { |
37
|
|
|
if ($result['success']) { |
38
|
|
|
$this->addFlashMessage($result['reason']); |
39
|
|
|
} else { |
40
|
|
|
$this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$this->redirect('index'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $tagName |
49
|
|
|
*/ |
50
|
|
|
public function banTagByNameAction($tagName) |
51
|
|
|
{ |
52
|
|
|
$results = $this->varnish |
53
|
|
|
->banByTag(new Tag($tagName)) |
54
|
|
|
->shutdown(); |
55
|
|
|
|
56
|
|
|
foreach ($results as $result) { |
57
|
|
|
if ($result['success']) { |
58
|
|
|
$this->addFlashMessage($result['reason']); |
59
|
|
|
} else { |
60
|
|
|
$this->addFlashMessage($result['reason'], '', AbstractMessage::ERROR); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$this->redirect('index'); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.