CoolCMS API

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

$componentParameters

protected array<string, mixed> $componentParameters = []

component parameters set by setComponentParameter()

$translatorDomain

protected string|null $translatorDomain = 'front.system.components.operatorContact'

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>

createComponent()

public createComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

formatPhone()

Phone for display: `420 724 720 468` grouped in threes.

public formatPhone(string $phone) : string
Parameters
$phone : string
Return values
string

formatPhoneHref()

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
string

getComponentParameter()

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
Container

getSettings()

public getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

hasServiceByType()

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
phpstan-assert-if-true

class-string $className

Return values
bool

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
string

render()

public render([string $style = 'Extended' ][, int|null $contactPageId = null ]) : void
Parameters
$style : string = 'Extended'

Extended (Contact page) or Basic (panel card)

$contactPageId : int|null = null

page id for the "Contact the operator" button (Basic style only; null = the button is not rendered)

setComponentParameter()

Sets a component parameter.

public setComponentParameter(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

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
template
Return values
T

frontPresenter()

Returns the front presenter the component is attached to (null outside the front end or when detached).

protected frontPresenter() : BasePresenter|null
Return values
BasePresenter|null

getTranslator()

protected getTranslator() : ITranslator
Return values
ITranslator

setTemplateFile()

protected setTemplateFile(string $dir, string $filename) : void
Parameters
$dir : string
$filename : string

setTranslator()

protected setTranslator(ITranslator $translator) : self
Parameters
$translator : ITranslator
Return values
self

createMultiplierComponent()

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

createStandardComponent()

Creates a standard component (not a multiplier).

private createStandardComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

loadAvatar()

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

loadOperator()

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>

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
Return values
string|null
On this page

Search results