Include the query part of the request, when generating the url for the datatables via a custom twig function.

This fixes issue #735, as without this the query gets not passed to the datatable
This commit is contained in:
Jan Böhmer 2024-10-16 23:57:02 +02:00
parent 15ad0ec9c0
commit 7d834ac8d7
11 changed files with 29 additions and 12 deletions

View file

@ -22,6 +22,7 @@ declare(strict_types=1);
*/
namespace App\Twig;
use Symfony\Component\HttpFoundation\Request;
use Twig\TwigFunction;
use App\Services\LogSystem\EventCommentNeededHelper;
use Twig\Extension\AbstractExtension;
@ -38,6 +39,22 @@ final class MiscExtension extends AbstractExtension
new TwigFunction('event_comment_needed',
fn(string $operation_type) => $this->eventCommentNeededHelper->isCommentNeeded($operation_type)
),
new TwigFunction('uri_without_host', $this->uri_without_host(...))
];
}
/**
* Similar to the getUri function of the request, but does not contain protocol and host.
* @param Request $request
* @return string
*/
public function uri_without_host(Request $request): string
{
if (null !== $qs = $request->getQueryString()) {
$qs = '?'.$qs;
}
return $request->getBaseUrl().$request->getPathInfo().$qs;
}
}