function HtmxContentViewSubscriber::renderHtmxResponse
Sets a minimal response render array on an `_htmx_route` route.
Parameters
\Symfony\Component\HttpKernel\Event\ViewEvent $event: The event to process.
File
-
core/
lib/ Drupal/ Core/ EventSubscriber/ HtmxContentViewSubscriber.php, line 38
Class
- HtmxContentViewSubscriber
- View subscriber rendering main content from `_htmx_route` option routes.
Namespace
Drupal\Core\EventSubscriberCode
public function renderHtmxResponse(ViewEvent $event) : void {
$htmxRoute = $this->routeMatch
->getRouteObject()
->getOption('_htmx_route') ?? FALSE;
$request = $event->getRequest();
$result = $event->getControllerResult();
if ($htmxRoute && is_array($result) && $request->getRequestFormat() === 'html') {
$response = $this->getHtmxRenderer()
->renderResponse($result, $request, $this->routeMatch);
$event->setResponse($response);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.