feat: add htmx server-side plumbing

This commit is contained in:
fromme committed 2026-09-13 14:47:21 +02:00
1 parent 3bfb5afef6
commit ef8a88ed2a
9 files changed
+450

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace App\Htmx;
use Symfony\Component\HttpFoundation\Response;
/**
* Response that makes htmx perform a full page navigation.
*
* htmx never follows a normal 3xx itself -- the browser does, transparently, and htmx then swaps
* whatever the final destination returned, which is a whole page in the wrong place. So a redirect
* has to be handed to htmx as an instruction instead: a 200 carrying HX-Redirect.
*
* Anything returning this from an event listener must also call
* ExceptionEvent::allowCustomResponseCode(), or the kernel overwrites the 200.
*/
class HxRedirectResponse extends Response
{
public function __construct(string $url)
{
parent::__construct('', Response::HTTP_OK, ['HX-Redirect' => $url]);
}
}