feat: add htmx server-side plumbing
This commit is contained in:
1 parent
3bfb5afef6
commit
ef8a88ed2a
9 files changed
+450
No files matched your search
@@ -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]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user