Bug #94533
Updated by Jarvis H over 3 years ago
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:
<pre><code class="php">
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;
}
</code></pre>
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:
<pre><code class="php">
protected $defaultViewObjectName = JsonView::class;
</code></pre>
Output is rendered like so:
<pre>
lib.myPlugin = USER
lib.myPlugin {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = MyPlugin
vendorName = ABC
extensionName = SomeExtension
controller = SomeController
}
JSONPAGE = PAGE
JSONPAGE {
config {
disableAllHeaderCode = 1
debug = 0
}
10 < lib.myPlugin
}
</pre>