* - 'h': html (aka `setHtmlEscape(TRUE)`)
* - 't': text (aka `setHtmlEscape(FALSE)`)
* - 's': ssl (aka `setSsl(TRUE)`)
+ * - 'c': cache code for resources (aka Civi::resources()->addCacheCode())
* FIXME: Should we have a flag for appending 'resCacheCode'?
* @return \Civi\Core\Url
* URL object which may be modified or rendered as text.
*/
private $fragment;
+ /**
+ * Whether to auto-append the cache-busting resource code.
+ *
+ * @var bool|null
+ * NULL definition TBD (either "off" or "automatic"?)
+ */
+ private $cacheCode;
+
/**
* Preferred format.
*
return $this;
}
+ /**
+ * @return bool|null
+ */
+ public function getCacheCode(): ?bool {
+ return $this->cacheCode;
+ }
+
+ /**
+ * Specify whether to append a cache-busting code.
+ *
+ * @param bool|null $cacheCode
+ * TRUE: Do append
+ * FALSE: Do not append
+ * @return $this;
+ */
+ public function setCacheCode(?bool $cacheCode) {
+ $this->cacheCode = $cacheCode;
+ return $this;
+ }
+
/**
* @return string|null
* 'relative' or 'absolute'
case 's';
$this->ssl = TRUE;
break;
+
+ // (c)ache code for resources
+ case 'c':
+ $this->cacheCode = TRUE;
+ break;
}
}
return $this;
throw new \RuntimeException("Unknown URL scheme: {$this->getScheme()}");
}
+ if ($this->cacheCode) {
+ $result = \Civi::resources()->addCacheCode($result);
+ }
+
// TODO decide if the current default is good enough for future
$ssl = $this->getSsl() ?: \CRM_Utils_System::isSSL();
if ($ssl && str_starts_with($result, 'http:')) {