function Htmx::locationHeader
Set HX-Location header.
Parameters
\Drupal\Core\Url|\Drupal\Core\Htmx\HtmxLocationResponseData $data: Use Url if only a path is needed.
Return value
static Self for chaining.
See also
https://htmx.org/headers/hx-location/
File
-
core/
lib/ Drupal/ Core/ Htmx/ Htmx.php, line 317
Class
- Htmx
- Presents the HTMX controls for developers to use with render arrays.
Namespace
Drupal\Core\HtmxCode
public function locationHeader(Url|HtmxLocationResponseData $data) : static {
if ($data instanceof HtmxLocationResponseData) {
$value = (string) $data;
$this->cacheableMetadata
->addCacheableDependency($data->getCacheableMetadata());
}
else {
$value = $this->urlValue($data);
}
$this->headers
->set('HX-Location', $value);
return $this;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.