-
-
Notifications
You must be signed in to change notification settings - Fork 218
/
LegacyFusionControllerContext.php
127 lines (117 loc) · 4.51 KB
/
LegacyFusionControllerContext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
declare(strict_types=1);
namespace Neos\Fusion\Core;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\ActionResponse;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\FlashMessage\FlashMessageContainer;
use Neos\Flow\Mvc\FlashMessage\FlashMessageService;
use Neos\Flow\Mvc\Routing\UriBuilder;
/**
* Legacy stub to replace the original {@see ControllerContext} inside Fusion {@see Runtime::getControllerContext()}.
*
* The concept of the controller context inside Fusion has been deprecated.
*
* You should definitely not pass this object along further, which will also most likely not work as it doesn't
* satisfy the constraint of `instanceof ControllerContext`!
*
* To migrate the use case of fetching the active request, please look into {@see FusionGlobals::get()} instead.
* By convention, an {@see ActionRequest} will be available as `request`:
*
* $actionRequest = $this->runtime->fusionGlobals->get('request');
* if (!$actionRequest instanceof ActionRequest) {
* // fallback or error
* }
*
* To get an {@see UriBuilder} proceed with:
*
* $uriBuilder = new UriBuilder();
* $uriBuilder->setRequest($actionRequest);
*
* WARNING regarding {@see Runtime::getControllerContext()}:
* Invoking this backwards-compatible layer is possibly unsafe, if the rendering was not started
* in {@see self::renderResponse()} or no `request` global is available. This will raise an exception.
*
* @deprecated with Neos 9.0 can be removed with 10
* @internal
*/
final class LegacyFusionControllerContext
{
/**
* @Flow\Inject
* @var FlashMessageService
*/
protected $flashMessageService;
public function __construct(
private readonly ActionRequest $request,
private readonly ActionResponse $legacyActionResponseForCurrentRendering
) {
}
/**
* To migrate the use case of fetching the active request, please look into {@see FusionGlobals::get()} instead.
* By convention, an {@see ActionRequest} will be available as `request`:
*
* $actionRequest = $this->runtime->fusionGlobals->get('request');
* if (!$actionRequest instanceof ActionRequest) {
* // fallback or error
* }
*
* @deprecated with Neos 9.0 can be removed with 10
*/
public function getRequest(): ActionRequest
{
return $this->request;
}
/**
* To migrate the use case of getting the UriBuilder please use this instead:
*
* $actionRequest = $this->runtime->fusionGlobals->get('request');
* if (!$actionRequest instanceof ActionRequest) {
* // fallback or error
* }
* $uriBuilder = new UriBuilder();
* $uriBuilder->setRequest($actionRequest);
*
* @deprecated with Neos 9.0 can be removed with 10
*/
public function getUriBuilder(): UriBuilder
{
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->request);
return $uriBuilder;
}
/**
* To migrate this use case please use {@see FlashMessageService::getFlashMessageContainerForRequest()} in
* combination with fetching the active request as described here {@see getRequest} instead.
*
* @deprecated with Neos 9.0 can be removed with 10
*/
public function getFlashMessageContainer(): FlashMessageContainer
{
return $this->flashMessageService->getFlashMessageContainerForRequest($this->request);
}
/**
* PURELY INTERNAL with partially undefined behaviour!!!
*
* Gives access to the legacy mutable action response simulation {@see Runtime::withSimulatedLegacyControllerContext()}
*
* Initially it was possible to mutate the current response of the active MVC controller through this getter.
*
* While *HIGHLY* internal behaviour and *ONLY* to be used by Neos.Fusion.Form or Neos.Neos:Plugin
* this legacy layer is in place to still allow this functionality.
*
* @deprecated with Neos 9.0 can be removed with 10
* @internal THIS SHOULD NEVER BE CALLED ON USER-LAND
*/
public function getResponse(): ActionResponse
{
// expose action response to be possibly mutated in neos forms or fusion plugins.
// this behaviour is highly internal and deprecated!
return $this->legacyActionResponseForCurrentRendering;
}
/**
* The method {@see ControllerContext::getArguments()} was removed without replacement.
*/
// public function getArguments(): Arguments;
}