Themes
extends AutoService
in package
AutoService is a base-class for defining a service (in Civi's service-container).
Tags
Table of Contents
Constants
- DEFAULT_THEME = 'greenwich'
- The "default" theme adapts based on the latest recommendation from civicrm.org by switching to DEFAULT_THEME at runtime.
- FALLBACK_THEME = '_fallback_'
- Fallback is a pseudotheme which can be included in "search_order".
- PASSTHRU = 'PASSTHRU'
Properties
- $activeThemeKey : string
- $cache : CRM_Utils_Cache_Interface
- $themes : array<string|int, mixed>
Methods
- __construct() : mixed
- Theme constructor.
- cssId() : string
- get() : array<string|int, mixed>|null
- Get the definition of the theme.
- getActiveThemeKey() : string
- Determine the name of active theme.
- getAll() : array<string|int, mixed>
- Get a list of all known themes, including hidden base themes.
- getAvailable() : array<string|int, mixed>
- Get a list of available themes, excluding hidden base themes.
- resolveUrls() : array<string|int, mixed>
- Get the URL(s) for a themed CSS file.
- build() : array<string|int, mixed>
- Apply defaults for a given them.
- buildAll() : array<string|int, mixed>
- Construct the list of available themes.
Constants
DEFAULT_THEME
The "default" theme adapts based on the latest recommendation from civicrm.org by switching to DEFAULT_THEME at runtime.
public
mixed
DEFAULT_THEME
= 'greenwich'
FALLBACK_THEME
Fallback is a pseudotheme which can be included in "search_order".
public
mixed
FALLBACK_THEME
= '_fallback_'
It locates files in the core/extension (non-theme) codebase.
PASSTHRU
public
mixed
PASSTHRU
= 'PASSTHRU'
Properties
$activeThemeKey
private
string
$activeThemeKey
= NULL
Ex: 'judy', 'liza'.
$cache
private
CRM_Utils_Cache_Interface
$cache
= NULL
$themes
private
array<string|int, mixed>
$themes
= NULL
Array(string $themeKey => array $themeSpec).
Methods
__construct()
Theme constructor.
public
__construct([CRM_Utils_Cache_Interface $cache = NULL ]) : mixed
Parameters
- $cache : CRM_Utils_Cache_Interface = NULL
cssId()
public
cssId(string $cssExt, string $cssFile) : string
Parameters
- $cssExt : string
- $cssFile : string
Return values
stringget()
Get the definition of the theme.
public
get(string $themeKey) : array<string|int, mixed>|null
Parameters
- $themeKey : string
-
Ex: 'greenwich', 'shoreditch'.
Tags
Return values
array<string|int, mixed>|nullgetActiveThemeKey()
Determine the name of active theme.
public
getActiveThemeKey() : string
Return values
string —Ex: "greenwich".
getAll()
Get a list of all known themes, including hidden base themes.
public
getAll() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —List of themes, keyed by name. Same format as CRM_Utils_Hook::themes(), but any default values are filled in.
getAvailable()
Get a list of available themes, excluding hidden base themes.
public
getAvailable() : array<string|int, mixed>
This is the same as getAll(), but abstract themes like "fallback" or "newyork_base" are omitted.
Tags
Return values
array<string|int, mixed> —List of themes. Ex: ['greenwich' => 'Greenwich', 'shoreditch' => 'Shoreditch'].
resolveUrls()
Get the URL(s) for a themed CSS file.
public
resolveUrls(string $active, string $cssExt, string $cssFile) : array<string|int, mixed>
This implements a prioritized search, in order:
- Check for the specified theme.
- If that doesn't exist, check for the default theme.
- If that doesn't exist, use the 'none' theme.
Parameters
- $active : string
-
Active theme key. Ex: 'greenwich'.
- $cssExt : string
-
Ex: 'civicrm'.
- $cssFile : string
-
Ex: 'css/bootstrap.css' or 'css/civicrm.css'.
Return values
array<string|int, mixed> —List of URLs to display. Ex: array(string $url)
build()
Apply defaults for a given them.
protected
build(string $themeKey, array<string|int, mixed> $theme) : array<string|int, mixed>
Parameters
- $themeKey : string
-
The name of the theme. Ex: 'greenwich'.
- $theme : array<string|int, mixed>
-
The original theme definition of the theme (per CRM_Utils_Hook::themes).
Tags
Return values
array<string|int, mixed> —The full theme definition of the theme (per CRM_Utils_Hook::themes).
buildAll()
Construct the list of available themes.
protected
buildAll() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —List of themes, keyed by name.