|
1
|
|
|
<?php |
|
2
|
|
|
namespace Aoe\Asdis\Middleware; |
|
3
|
|
|
|
|
4
|
|
|
use Aoe\Asdis\Domain\Model\Asset\Collection; |
|
5
|
|
|
use Aoe\Asdis\Domain\Model\Page; |
|
6
|
|
|
use Aoe\Asdis\System\Configuration\Provider; |
|
7
|
|
|
use Aoe\Asdis\System\Log\Logger; |
|
8
|
|
|
use Psr\Http\Message\ResponseFactoryInterface; |
|
9
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
10
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
11
|
|
|
use Psr\Http\Server\MiddlewareInterface; |
|
12
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
|
13
|
|
|
use TYPO3\CMS\Core\Http\HtmlResponse; |
|
14
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
15
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
16
|
|
|
|
|
17
|
|
|
class ContentPostProcAll implements MiddlewareInterface |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \Aoe\Asdis\Domain\Model\Page |
|
21
|
|
|
*/ |
|
22
|
|
|
private $page; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param array $params |
|
|
|
|
|
|
26
|
|
|
* @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj |
|
|
|
|
|
|
27
|
|
|
* @return void |
|
28
|
|
|
*/ |
|
29
|
|
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
|
30
|
|
|
{ |
|
31
|
|
|
$response = $handler->handle($request); |
|
32
|
|
|
|
|
33
|
|
|
if ($this->getConfigurationProvider()->isDefaultHookHandlingDisabled()) { |
|
34
|
|
|
return $response; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
try { |
|
38
|
|
|
$this->setPageObject($GLOBALS['TSFE']); |
|
39
|
|
|
$this->scrapeAndReplace(); |
|
40
|
|
|
$response = new HtmlResponse($this->page->getPageObject()->content); |
|
41
|
|
|
} catch(\Exception $e) { |
|
42
|
|
|
$this->getLogger()->logException(__METHOD__, $e); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
return $response; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @return Provider |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function getConfigurationProvider() |
|
52
|
|
|
{ |
|
53
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
54
|
|
|
return $objectManager->get(Provider::class); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return Logger |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getLogger() |
|
61
|
|
|
{ |
|
62
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
63
|
|
|
return $objectManager->get(Logger::class); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return void |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function scrapeAssets() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->page->scrapeAssets(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @return void |
|
76
|
|
|
*/ |
|
77
|
|
|
protected function replaceAssets() |
|
78
|
|
|
{ |
|
79
|
|
|
$this->page->replaceAssets(); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Scrapes and replaces the assets of the current page. |
|
84
|
|
|
* |
|
85
|
|
|
* @return void |
|
86
|
|
|
*/ |
|
87
|
|
|
protected function scrapeAndReplace() |
|
88
|
|
|
{ |
|
89
|
|
|
$this->scrapeAssets(); |
|
90
|
|
|
$this->replaceAssets(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj |
|
95
|
|
|
*/ |
|
96
|
|
|
protected function setPageObject(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $pObj) |
|
97
|
|
|
{ |
|
98
|
|
|
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
|
99
|
|
|
/** @var \Aoe\Asdis\Domain\Model\Page $page */ |
|
100
|
|
|
$page = $objectManager->get(Page::class); |
|
101
|
|
|
$page->setAssets($objectManager->get(Collection::class)); |
|
102
|
|
|
$page->setPageObject($pObj); |
|
103
|
|
|
$this->page = $page; |
|
104
|
|
|
} |
|
105
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.