ThemeHelper
in package
Table of Contents
Properties
- $httpRequest : Request|null
- $themeResolver : ThemeResolverInterface|null
Methods
- getAssetPath() : string
- getAssetVersion() : string
- Returns a cache-buster derived from `filemtime()` of the file actually served.
- getSkinPath() : string|null
- Returns the relative path to the CSS of the active skin, or null when the template uses its base colors.
- getThemeUrl() : string
- getVersionedAssetUrl() : string
- Returns `getAssetPath()` with the `?v=<filemtime>` cache-buster in one call; see {@see getAssetVersion()}.
- init() : void
- isTheme() : bool
- __construct() : mixed
- constructUrl() : string
- httpRequest() : Request
- theme() : Theme
- Returns the active theme; calling it without `init()` or before the theme is resolved is a caller error.
Properties
$httpRequest
private
static Request|null
$httpRequest
= null
$themeResolver
private
static ThemeResolverInterface|null
$themeResolver
= null
Methods
getAssetPath()
public
static getAssetPath(string $path) : string
Parameters
- $path : string
Return values
stringgetAssetVersion()
Returns a cache-buster derived from `filemtime()` of the file actually served.
public
static getAssetVersion(string $path) : string
A buster that changes on every request (such as {time()} in a template) keeps browsers
and shared caches from ever treating the asset as fresh.
Parameters
- $path : string
Return values
stringgetSkinPath()
Returns the relative path to the CSS of the active skin, or null when the template uses its base colors.
public
static getSkinPath() : string|null
A skin is a thin :root { --* } layer linked after style.css, so one extra file is
enough instead of a second copy of the styles. The choice is made by
DefaultThemeResolver::applySkinOverride(); only a verified name
arrives here, so file existence is not checked again.
NOTE: it goes through getAssetPath(), so a tablet or mobile variant without its own skin gets the desktop one; skins are not duplicated per device variant.
Return values
string|nullgetThemeUrl()
public
static getThemeUrl(string $path) : string
Parameters
- $path : string
Return values
stringgetVersionedAssetUrl()
Returns `getAssetPath()` with the `?v=<filemtime>` cache-buster in one call; see {@see getAssetVersion()}.
public
static getVersionedAssetUrl(string $path) : string
Parameters
- $path : string
Return values
stringinit()
public
static init(ThemeResolverInterface $themeResolver, Request $httpRequest) : void
Parameters
- $themeResolver : ThemeResolverInterface
- $httpRequest : Request
isTheme()
public
static isTheme(string $name) : bool
Parameters
- $name : string
Return values
bool__construct()
private
__construct() : mixed
constructUrl()
private
static constructUrl(string $variant, string $path[, bool $absolutePath = false ]) : string
Parameters
- $variant : string
- $path : string
- $absolutePath : bool = false
Return values
stringhttpRequest()
private
static httpRequest() : Request
Return values
Requesttheme()
Returns the active theme; calling it without `init()` or before the theme is resolved is a caller error.
private
static theme() : Theme