wip: feedback about booked and assigned rooms
This commit is contained in:
1 parent
9d99fe9272
commit
b44d8505b2
4 files changed
+126
-46
No files matched your search
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Traits;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Provides helper methods for handling HTMX responses.
|
||||
*
|
||||
* This trait should be used in controllers that extend Symfony's AbstractController,
|
||||
* as it relies on the renderBlockView() method.
|
||||
*/
|
||||
trait HtmxControllerTrait
|
||||
{
|
||||
/**
|
||||
* Renders multiple Twig blocks for an HTMX Out-of-Band swap response.
|
||||
*
|
||||
* @param string $templateName the name of the Twig template
|
||||
* @param string[] $blockNames an array of block names to render
|
||||
* @param array<string, mixed> $context the context to pass to the template
|
||||
*/
|
||||
protected function htmxOobResponse(string $templateName, array $blockNames, array $context = []): Response
|
||||
{
|
||||
$html = '';
|
||||
// Add a flag to the context so templates can conditionally add the hx-swap-oob attribute.
|
||||
$oobContext = $context + ['htmx_oob_swap' => true];
|
||||
|
||||
foreach ($blockNames as $blockName) {
|
||||
// Use renderBlockView() to get the raw HTML string for each block.
|
||||
$html .= $this->renderBlockView($templateName, $blockName, $oobContext);
|
||||
}
|
||||
|
||||
return new Response($html);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user