OperatorContact
extends BaseComponent
in package
Website operator: who runs the website and how to reach them.
Reads the web.operator.* keys of module 1 (cms_system_settings), edited in the admin
screen "Settings / Operator" (OperatorPresenter).
All keys are is_public = 1 so they pass the public settings map (getPublicMerged); a
future non-public key would silently not render on the front end instead of failing.
Two styles:
Extended(default): full listing, the Contact page:{control frontSystemOperatorContact}Basic: card for a panel or the home page, introduction plus a link to the contact page:{control frontSystemOperatorContact:basic 2003}(argument = contact page id)
NOTE: email.info and phone.info are optional supplementary texts under the contact
(for example a response-time note); an empty value renders no line.
Table of Contents
Constants
- KEY_AVATAR : mixed = 'web.operator.avatar.assetId'
- Settings key with the asset id of the operator photo/logo.
- KEY_PREFIX : mixed = 'web.operator.'
- Common prefix of all operator keys.
- MODULE : mixed = 1
- Index of module "System" in the settings table.
- TEXT_KEYS : mixed = ['name', 'claim', 'perex', 'address.street', 'a...
- Keys (without prefix) that templates need as plain text.
Properties
- $container : Container
- $routerDispatcher : RouterDispatcher
- $translator : ITranslator
- $appContext : AppContext
- $componentParameters : array<string, mixed>
- $currencyContext : CurrencyContext|null
- $deviceDetector : DeviceDetector|null
- $languageContext : LanguageContext|null
- $localizationContext : LocalizationContext|null
- $settingContext : SettingContext
- $themeContext : ThemeContext|null
- $translatorDomain : string|null
- $assetManager : AssetManager
Methods
- __call() : mixed
- Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
- __construct() : mixed
- createComponent() : IComponent|null
- formatPhone() : string
- Phone for display: `420 724 720 468` grouped in threes.
- formatPhoneHref() : string
- Phone for the `tel:` link: without spaces and with a leading `+`. The settings store it as `420724720468` (no plus), which would be an invalid `tel:` link in `href`.
- getAppContext() : AppContext
- getComponentParameter() : mixed
- Returns a component parameter, or null when it is not set.
- getContainer() : Container
- getCurrencyContext() : CurrencyContext|null
- getLanguageContext() : LanguageContext|null
- getLocalizationContext() : LocalizationContext|null
- getRouterDispatcher() : RouterDispatcher
- getSettingContext() : SettingContext
- getSettings() : array<int, array<string, mixed>>
- getThemeContext() : ThemeContext|null
- hasServiceByType() : bool
- Returns whether the container has a service of the given type.
- initializeAllContexts() : void
- initials() : string
- Initials for the circle when the operator has no uploaded photo: `Ing. John Smith` gives `LO`.
- injectDeviceDetector() : void
- onCreate() : void
- render() : void
- setAppContext() : $this
- setComponentParameter() : void
- Sets a component parameter.
- setCurrencyContext() : $this
- setLanguageContext() : $this
- setLocalizationContext() : $this
- setSettingContext() : $this
- setThemeContext() : $this
- setup() : void
- setupAppContext() : void
- typedComponent() : T
- Returns a subcomponent with a verified type.
- frontPresenter() : BasePresenter|null
- Returns the front presenter the component is attached to (null outside the front end or when detached).
- getTranslator() : ITranslator
- setTemplateFile() : void
- setTranslator() : self
- createMultiplierComponent() : Multiplier<string|int, IComponent>
- Creates a multiplier for the component.
- createNewComponentInstance() : IComponent|null
- Creates a new component instance without adding it to the presenter; used by the multiplier.
- createStandardComponent() : IComponent|null
- Creates a standard component (not a multiplier).
- loadAvatar() : Asset|null
- Operator photo/logo, or null.
- loadOperator() : array<string, string>
- Operator values as a flat map. A missing or empty key gives '', so the template skips the line and an unfilled value leaves no gap.
- resolveContactLink() : string|null
- Link to the contact page, or null.
Constants
KEY_AVATAR
Settings key with the asset id of the operator photo/logo.
private
mixed
KEY_AVATAR
= 'web.operator.avatar.assetId'
KEY_PREFIX
Common prefix of all operator keys.
private
mixed
KEY_PREFIX
= 'web.operator.'
MODULE
Index of module "System" in the settings table.
private
mixed
MODULE
= 1
TEXT_KEYS
Keys (without prefix) that templates need as plain text.
private
mixed
TEXT_KEYS
= ['name', 'claim', 'perex', 'address.street', 'address.zip', 'address.city', 'address.country', 'regNo', 'vatId', 'email', 'email.info', 'phone', 'phone.info', 'info']
The photo is separate: the settings hold only the asset id, not a value to print.
Properties
$container
public
Container
$container
Attributes
- #[Inject]
$routerDispatcher
public
RouterDispatcher
$routerDispatcher
$translator
public
ITranslator
$translator
Tags
$appContext
protected
AppContext
$appContext
$componentParameters
protected
array<string, mixed>
$componentParameters
= []
component parameters set by setComponentParameter()
$currencyContext
protected
CurrencyContext|null
$currencyContext
= NULL
$deviceDetector
protected
DeviceDetector|null
$deviceDetector
= NULL
$languageContext
protected
LanguageContext|null
$languageContext
= NULL
$localizationContext
protected
LocalizationContext|null
$localizationContext
= NULL
$settingContext
protected
SettingContext
$settingContext
$themeContext
protected
ThemeContext|null
$themeContext
= NULL
$translatorDomain
protected
string|null
$translatorDomain
= 'front.system.components.operatorContact'
$assetManager read-only
private
AssetManager
$assetManager
Methods
__call()
Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
public
__call(string $name, array<string|int, mixed> $args) : mixed
Called only when the component has no renderXyz() method of its own.
Parameters
- $name : string
- $args : array<string|int, mixed>
__construct()
public
__construct(AssetManager $assetManager) : mixed
Parameters
- $assetManager : AssetManager
createComponent()
public
createComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullformatPhone()
Phone for display: `420 724 720 468` grouped in threes.
public
formatPhone(string $phone) : string
Parameters
- $phone : string
Return values
stringformatPhoneHref()
Phone for the `tel:` link: without spaces and with a leading `+`. The settings store it as `420724720468` (no plus), which would be an invalid `tel:` link in `href`.
public
formatPhoneHref(string $phone) : string
Parameters
- $phone : string
Return values
stringgetAppContext()
public
getAppContext() : AppContext
Return values
AppContextgetComponentParameter()
Returns a component parameter, or null when it is not set.
public
getComponentParameter(string $name) : mixed
Parameters
- $name : string
getContainer()
public
getContainer() : Container
Return values
ContainergetCurrencyContext()
public
getCurrencyContext() : CurrencyContext|null
Return values
CurrencyContext|nullgetLanguageContext()
public
getLanguageContext() : LanguageContext|null
Return values
LanguageContext|nullgetLocalizationContext()
public
getLocalizationContext() : LocalizationContext|null
Return values
LocalizationContext|nullgetRouterDispatcher()
public
getRouterDispatcher() : RouterDispatcher
Return values
RouterDispatchergetSettingContext()
public
getSettingContext() : SettingContext
Return values
SettingContextgetSettings()
public
getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>getThemeContext()
public
getThemeContext() : ThemeContext|null
Return values
ThemeContext|nullhasServiceByType()
Returns whether the container has a service of the given type.
public
hasServiceByType(string $className) : bool
The name is composed dynamically (module plus component), so class_exists() runs first, and
a true result guarantees a valid type.
Parameters
- $className : string
Tags
Return values
boolinitializeAllContexts()
public
initializeAllContexts() : void
initials()
Initials for the circle when the operator has no uploaded photo: `Ing. John Smith` gives `LO`.
public
initials(string $name) : string
Titles and one-letter words (Ing., s.r.o.) are skipped, otherwise a company name would
yield legal-form abbreviations instead of the name. If nothing is left after the filter,
the first letter of the whole name is used.
Parameters
- $name : string
Return values
stringinjectDeviceDetector()
public
injectDeviceDetector(DeviceDetector $detector) : void
Parameters
- $detector : DeviceDetector
onCreate()
public
onCreate() : void
render()
public
render([string $style = 'Extended' ][, int|null $contactPageId = null ]) : void
Parameters
- $style : string = 'Extended'
-
Extended(Contact page) orBasic(panel card) - $contactPageId : int|null = null
-
page id for the "Contact the operator" button (
Basicstyle only; null = the button is not rendered)
setAppContext()
public
setAppContext(AppContext $appContext) : $this
Parameters
- $appContext : AppContext
Return values
$thissetComponentParameter()
Sets a component parameter.
public
setComponentParameter(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setCurrencyContext()
public
setCurrencyContext(CurrencyContext|null $currencyContext) : $this
Parameters
- $currencyContext : CurrencyContext|null
Return values
$thissetLanguageContext()
public
setLanguageContext(LanguageContext|null $languageContext) : $this
Parameters
- $languageContext : LanguageContext|null
Return values
$thissetLocalizationContext()
public
setLocalizationContext(LocalizationContext|null $localizationContext) : $this
Parameters
- $localizationContext : LocalizationContext|null
Return values
$thissetSettingContext()
public
setSettingContext(SettingContext $settingContext) : $this
Parameters
- $settingContext : SettingContext
Return values
$thissetThemeContext()
public
setThemeContext(ThemeContext|null $themeContext) : $this
Parameters
- $themeContext : ThemeContext|null
Return values
$thissetup()
public
setup(BasePresenter|BasePresenter $presenter) : void
Parameters
- $presenter : BasePresenter|BasePresenter
setupAppContext()
public
setupAppContext(AppContext $appContext) : void
Parameters
- $appContext : AppContext
typedComponent()
Returns a subcomponent with a verified type.
public
typedComponent(string $name, T> $type) : T
Use it instead of an inline @var above $this['x'] (which does not narrow the type) and
instead of the generic IComponent that $this['x'] returns. See
Form::typedComponent().
Parameters
- $name : string
- $type : T>
Tags
Return values
TfrontPresenter()
Returns the front presenter the component is attached to (null outside the front end or when detached).
protected
frontPresenter() : BasePresenter|null
Return values
BasePresenter|nullgetTranslator()
protected
getTranslator() : ITranslator
Return values
ITranslatorsetTemplateFile()
protected
setTemplateFile(string $dir, string $filename) : void
Parameters
- $dir : string
- $filename : string
setTranslator()
protected
setTranslator(ITranslator $translator) : self
Parameters
- $translator : ITranslator
Return values
selfcreateMultiplierComponent()
Creates a multiplier for the component.
private
createMultiplierComponent(string $name) : Multiplier<string|int, IComponent>
Parameters
- $name : string
Return values
Multiplier<string|int, IComponent>createNewComponentInstance()
Creates a new component instance without adding it to the presenter; used by the multiplier.
private
createNewComponentInstance(string $baseName[, int|string|null $uniqueKey = null ]) : IComponent|null
Parameters
- $baseName : string
- $uniqueKey : int|string|null = null
Return values
IComponent|nullcreateStandardComponent()
Creates a standard component (not a multiplier).
private
createStandardComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullloadAvatar()
Operator photo/logo, or null.
private
loadAvatar() : Asset|null
Fail-soft: the settings hold only the id, so a deleted asset is simply not loaded and the card falls back to initials (initials()); a missing image must not take the page down. The query is sent only when the id is filled.
Return values
Asset|nullloadOperator()
Operator values as a flat map. A missing or empty key gives '', so the template skips the line and an unfilled value leaves no gap.
private
loadOperator() : array<string, string>
Return values
array<string, string>resolveContactLink()
Link to the contact page, or null.
private
resolveContactLink(int $pageId) : string|null
IMPORTANT: the action is form, not show: the contact page has a component (form) set
in cms_system_pages, which PageShowRouteFactory routes to the form action. Through
show the link would lead to a page without the form.
IMPORTANT: getDefaultUrlParams() resets persistent parameters (paging, filters, sorting);
without them the state of the page the card is rendered from would leak into the link
(BasePresenter::DEFAULT_URL_PARAMS).
IMPORTANT: slug must be on the left of +. DEFAULT_URL_PARAMS contains 'slug' => null
and an array union keeps the value from the left side; the reverse order passes an empty
slug to link() and Nette fails with "No route for Front:System:Page:form()".
Parameters
- $pageId : int