Actions
Bug #94533
closedExtbase controller response status not working
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-07-10
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
Extbase controller actions can now return a ResponseInterface.
According to the migration notes here: https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/11.0/Deprecation-92784-ExtbaseControllerActionsMustReturnResponseInterface.html#migration it should be possible to change the response code using withStatus:
public function listAction(): ResponseInterface
{
$items = $this->itemRepository->findAll();
$this->view->assign('items', $items);
$response = $this->responseFactory
->createResponse()
->withHeader('Cache-Control', 'must-revalidate')
->withHeader('Content-Type', 'text/html; charset=utf-8')
->withStatus(200, 'Super ok!');
$response->getBody()->write($this->view->render());
return $response;
}
However, the response code always stays at '200' regardless of entering fx. '400'.
Additional info:
Typo3 Version: 11.2 & 11.3
I am using the jsonView in my extbase controller:
protected $defaultViewObjectName = JsonView::class;
Output is rendered like so:
lib.myPlugin = USER lib.myPlugin { userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run pluginName = MyPlugin vendorName = ABC extensionName = SomeExtension controller = SomeController } JSONPAGE = PAGE JSONPAGE { typeNum = 123 config { disableAllHeaderCode = 1 debug = 0 } 10 < lib.myPlugin }
Actions