SiteIdentityInitTrait
Site identity (logo, favicon, name, tagline, author) in the template variable `$identity`.
The values are edited by the administrator on the site identity screen
(SiteIdentityPresenter); module 1 settings store
only asset ids, the images live in cms_system_images.
IMPORTANT: the keys must have is_public = 1, otherwise the front end never receives them
(see SettingInitTrait). They are read from
settingContext, not $this->template->settings, because the context holds the full map.
The name and tagline are language dependent: <key>.<page language alias> (site.name.en)
with a fallback to the base key of the default language, see LocalizedSettingKey.
The author and images are shared by all languages. Assets load by one IN query, none when nothing is set.
Table of Contents
Constants
- IDENTITY_LOCALIZED_KEYS : mixed = ['site.name', 'site.tagline']
- Text identity keys that have language variants `<key>.<alias>`.
- IDENTITY_ASSET_KEYS : mixed = ['site.logo.assetId' => 'setLogo', 'site.logo.d...
- Setting key to DTO setter; the order matches the form fields.
- IDENTITY_MODULE : mixed = 1
- Identity settings live in the System module.
Properties
Methods
- buildSiteIdentity() : SiteIdentityDto
- initSiteIdentity() : void
- identitySetting() : string
- Returns the module 1 key value as a string (empty when the key is missing or not a scalar).
- identitySettingOrNull() : string|null
- Works like {@see identitySetting()}, but an empty value is null (the template omits the field).
- loadIdentityAssets() : array<int, Asset>
- Loads the identity assets by id, keyed by id.
- localizedIdentitySetting() : string
- Returns the language-dependent identity value: `<key>.<page language alias>`; an empty or missing value falls back to the base key (default language). An empty string means neither is set.
Constants
IDENTITY_LOCALIZED_KEYS
Text identity keys that have language variants `<key>.<alias>`.
public
mixed
IDENTITY_LOCALIZED_KEYS
= ['site.name', 'site.tagline']
IDENTITY_ASSET_KEYS
Setting key to DTO setter; the order matches the form fields.
private
mixed
IDENTITY_ASSET_KEYS
= ['site.logo.assetId' => 'setLogo', 'site.logo.dark.assetId' => 'setLogoDark', 'site.favicon.assetId' => 'setFavicon', 'site.og.assetId' => 'setOgImage']
IDENTITY_MODULE
Identity settings live in the System module.
private
mixed
IDENTITY_MODULE
= 1
Properties
$identityAssetManager
public
AssetManager
$identityAssetManager
Attributes
- #[Inject]
$siteIdentity
protected
SiteIdentityDto|null
$siteIdentity
= null
Methods
buildSiteIdentity()
protected
buildSiteIdentity() : SiteIdentityDto
Return values
SiteIdentityDtoinitSiteIdentity()
protected
initSiteIdentity() : void
identitySetting()
Returns the module 1 key value as a string (empty when the key is missing or not a scalar).
private
identitySetting(string $key) : string
Parameters
- $key : string
Return values
stringidentitySettingOrNull()
Works like {@see identitySetting()}, but an empty value is null (the template omits the field).
private
identitySettingOrNull(string $key) : string|null
Parameters
- $key : string
Return values
string|nullloadIdentityAssets()
Loads the identity assets by id, keyed by id.
private
loadIdentityAssets(array<int, int> $ids) : array<int, Asset>
Fail-soft: a deleted asset (its id remains in settings) is simply not loaded and the template falls back; a missing logo must not take down the whole front end.
Parameters
- $ids : array<int, int>
Return values
array<int, Asset>localizedIdentitySetting()
Returns the language-dependent identity value: `<key>.<page language alias>`; an empty or missing value falls back to the base key (default language). An empty string means neither is set.
private
localizedIdentitySetting(string $baseKey) : string
Parameters
- $baseKey : string