function HtmxLocationResponseData::__toString
Returns non-empty data, JSON encoded.
Return value
string The encoded data.
File
-
core/
lib/ Drupal/ Core/ Htmx/ HtmxLocationResponseData.php, line 62
Class
- HtmxLocationResponseData
- Optional data object for HX-Location.
Namespace
Drupal\Core\HtmxCode
public function __toString() : string {
/** @var \Drupal\Core\GeneratedUrl $generatedUrl */
$generatedUrl = $this->path
->toString(TRUE);
$this->cacheableMetadata
->addCacheableDependency($generatedUrl);
$path = $generatedUrl->getGeneratedUrl();
$data = [
'path' => $path,
'source' => $this->source,
'event' => $this->event,
'headers' => $this->headers,
'handler' => $this->handler,
'target' => $this->target,
'swap' => $this->swap,
'select' => $this->select,
'values' => $this->values,
];
$data = array_filter($data, static fn($item) => $item !== '' && $item !== []);
return json_encode($data);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.