CoolCMS API

ThemeHelper
in package

FinalYes

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

Methods

getAssetPath()

public static getAssetPath(string $path) : string
Parameters
$path : string
Return values
string

getAssetVersion()

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
string

getSkinPath()

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|null

getThemeUrl()

public static getThemeUrl(string $path) : string
Parameters
$path : string
Return values
string

getVersionedAssetUrl()

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
string

isTheme()

public static isTheme(string $name) : bool
Parameters
$name : string
Return values
bool

constructUrl()

private static constructUrl(string $variant, string $path[, bool $absolutePath = false ]) : string
Parameters
$variant : string
$path : string
$absolutePath : bool = false
Return values
string

httpRequest()

private static httpRequest() : Request
Return values
Request

theme()

Returns the active theme; calling it without `init()` or before the theme is resolved is a caller error.

private static theme() : Theme
Return values
Theme
On this page

Search results