1
|
|
|
<?php |
2
|
|
|
namespace Aoe\Varnish\TYPO3\Hooks; |
3
|
|
|
|
4
|
|
|
/*************************************************************** |
5
|
|
|
* Copyright notice |
6
|
|
|
* |
7
|
|
|
* (c) 2019 AOE GmbH <[email protected]> |
8
|
|
|
* |
9
|
|
|
* All rights reserved |
10
|
|
|
* |
11
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
12
|
|
|
* free software; you can redistribute it and/or modify |
13
|
|
|
* it under the terms of the GNU General Public License as published by |
14
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
15
|
|
|
* (at your option) any later version. |
16
|
|
|
* |
17
|
|
|
* The GNU General Public License can be found at |
18
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
19
|
|
|
* |
20
|
|
|
* This script is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
26
|
|
|
***************************************************************/ |
27
|
|
|
|
28
|
|
|
use Aoe\Varnish\Domain\Model\Tag\PageTag; |
29
|
|
|
use Aoe\Varnish\Domain\Model\Tag\PageIdTag; |
30
|
|
|
use Aoe\Varnish\System\Header; |
31
|
|
|
use Aoe\Varnish\TYPO3\Configuration\ExtensionConfiguration; |
32
|
|
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; |
33
|
|
|
|
34
|
|
|
class ContentPostProcOutputHook extends AbstractHook |
35
|
|
|
{ |
36
|
|
|
const TYPO3_PAGE_TAG = 'typo3_page'; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var Header |
40
|
|
|
*/ |
41
|
|
|
private $header; |
42
|
|
|
|
43
|
3 |
|
public function __construct() |
44
|
|
|
{ |
45
|
3 |
|
parent::__construct(); |
46
|
3 |
|
$this->header = new Header(); |
47
|
3 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param array $parameters |
51
|
|
|
* @param TypoScriptFrontendController $parent |
52
|
|
|
*/ |
53
|
3 |
|
public function sendHeader(array $parameters, TypoScriptFrontendController $parent) |
|
|
|
|
54
|
|
|
{ |
55
|
3 |
|
$this->sendPageTagHeader($parent); |
56
|
3 |
|
$this->sendDebugHeader(); |
57
|
3 |
|
if ((int)$parent->page['varnish_cache'] === 1) { |
58
|
2 |
|
$this->header->sendEnabledHeader(); |
59
|
|
|
} |
60
|
3 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param TypoScriptFrontendController $parent |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
3 |
|
private function sendPageTagHeader(TypoScriptFrontendController $parent) |
67
|
|
|
{ |
68
|
3 |
|
$pageIdTag = new PageIdTag($parent->id); |
69
|
3 |
|
$pageTag = new PageTag(self::TYPO3_PAGE_TAG); |
|
|
|
|
70
|
|
|
|
71
|
3 |
|
$this->header->sendHeaderForTag($pageIdTag); |
72
|
3 |
|
$this->header->sendHeaderForTag($pageTag); |
73
|
3 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
3 |
|
private function sendDebugHeader() |
79
|
|
|
{ |
80
|
|
|
/** @var ExtensionConfiguration $configuration */ |
81
|
3 |
|
$configuration = $this->objectManager->get(ExtensionConfiguration::class); |
82
|
3 |
|
if ($configuration->isDebug()) { |
83
|
2 |
|
$this->header->sendDebugHeader(); |
84
|
|
|
} |
85
|
3 |
|
} |
86
|
|
|
} |
87
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.