Bug #99476
closedAdd getRequest to RenderingContextInterface? (>= v11)
0%
Description
RenderingContextInterface does not contain getRequest().
If extending from AbstractViewHelper and using renderStatic, the function looks like this:
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
It should be possible to call $renderingContext->getRequest(), but then checks with phpstan will fail and you would have to check for the class name of the object (which should not really be necessary.
(Previously, it was possible to call $renderingContext->getControllerContext()->getRequest()).
Updated by Sybille Peters almost 2 years ago
Bloddy hill, the getRequest() function is @internal.
/**
* @return Request
* @internal this might change to use a PSR-7 compliant request
*/
public function getRequest(): Request
{
This contradicts the changelog:
Method getRequest() is available in controllers directly, and view-helpers receive the current request by calling RenderingContext->getRequest()
Updated by Sybille Peters almost 2 years ago
- Related to Bug #99475: Imcomplete deprecation (without trigger etc.) of RenderingContext::getControllerContext and ControllerContext functions (v11) added
Updated by Christian Kuhn almost 2 years ago
- Status changed from New to Rejected
Yeah, that situation is a bit unfortunate:
RenderingContextInterface is from fluid standalone. We can't add a method without being breaking in fluid standalone, which would trigger a major release, plus a dependency to psr-7 in fluid standalone.
We also can't extend the interface in core, since that would be liskov contravariant with the view helper interface signatures, so a changing type hints on the VH interfaces is not an option, either.
For now, core has to live with the situation.
Note getRequest() is no longer internal in RenderingContext in v12.
Updated by Sybille Peters almost 2 years ago
Christian, Thank you for the explanation!