CoolCMS API

Profile extends BaseComponent
in package
uses InitTrait

FinalYes

Presentation profile of the own company: the only place the template takes the company data itself from (name, slogan, perex, description, logo, hero photo, contact). The other components of the module list its parts (price list, references, parameters); this one lists the company.

Data comes from CompanyManager::findPresented(), a bridge to the narrow Api action presented (the server picks the presented company itself; the front end never sends companyId). Logo and hero photo are loaded separately through AssetManager: Company carries only a scalar FK, not an ORM association (same as ReferenceList).

Styles:

  • Hero: intro block of the home page (slogan, perex, photo, call to action),
  • Topbar: header contact strip (phone, e-mail, today's hours),
  • AboutMedia: composition of profile gallery photos for the "about us" section (items 1+2, 0 is the hero); without enough photos nothing is rendered,
  • QualityMedia: one gallery photo for the "quality" section (item 3),
  • Portrait: the hero photo (item 0) for a "quote" section, on a theme whose Hero does not show it,
  • Gallery: strip of profile gallery photos (items 4+), the "gallery" section,
  • FooterBrand, Contact, Copyright: footer brand (logo, name, perex), contact column (address, phone, e-mail) and copyright row (year + name),
  • Testimonials: client ratings through the Base Rating (style Reviews) over the rating thread of the company; gate: ratingEnabled + an existing thread, otherwise nothing is rendered.

IMPORTANT: one instance is rendered several times on a page (topbar + intro + reviews). Templates must not print a bare {$uniqueId}, otherwise the id would be tripled; each style adds its own suffix to it.

Table of Contents

Constants

TESTIMONIALS_PER_PAGE  : mixed = 3
How many client reviews are shown at once (a row of cards).

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
$company  : Company|null
Presented company; loaded once per request (`createComponentRating` calls it too).
$companyLoaded  : bool
$companyManager  : CompanyManager
$ratingFactory  : RatingFactory

Methods

__call()  : mixed
Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
__construct()  : mixed
createComponent()  : IComponent|null
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
injectDeviceDetector()  : void
onCreate()  : void
render()  : void
renderAboutMedia()  : void
Composition of gallery photos for the "about us" section (items 1+2, the hero is 0).
renderContact()  : void
Footer contact column: address, phone, e-mail.
renderCopyright()  : void
Footer copyright row: year + company name.
renderFooterBrand()  : void
Footer brand: logo, name and perex of the company.
renderGallery()  : void
Strip of profile gallery photos (items 4+): the "gallery" section of the home page.
renderHero()  : void
Intro block of the home page.
renderPortrait()  : void
Portrait for the "quote" section of the red law-firm theme.
renderQualityMedia()  : void
Gallery photo for the "quality" section (item 3).
renderTestimonials()  : void
Client ratings: the Base `RatingComponent` over the company thread.
renderTopbar()  : void
Header contact strip: phone, e-mail, today's opening hours.
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.
createComponentRating()  : Rating
Client reviews. The thread belongs to the company (`ratingThreadId`) and is created automatically when the company is saved (Api `CompanyManager` self-heal), so it is only taken over here, never created.
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).
loadAsset()  : Asset|null
Returns the asset by its scalar FK (`Company` carries no ORM association), or null.
prepareCompany()  : void
Loads the company + image channels (logo, hero photo) + the profile gallery. Without a presented company `$company` stays null and templates render nothing; on the front end that is a legitimate state (the company is not set up yet), not an error.
prepareTodayHours()  : void
Returns the opening hours of today and whether it is open right now.
resolveTranslation()  : object|null
Returns the company translation in the current language. `LanguageContext::getLang()` returns `int|string|null` (the route can hold an alias) while `getTranslation()` wants an int; without a numeric language the translation is simply not found.

Constants

TESTIMONIALS_PER_PAGE

How many client reviews are shown at once (a row of cards).

private mixed TESTIMONIALS_PER_PAGE = 3

Properties

$componentParameters

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

component parameters set by setComponentParameter()

$translatorDomain

protected string|null $translatorDomain = 'front.company.components.profile'

$company

Presented company; loaded once per request (`createComponentRating` calls it too).

private Company|null $company = null

$companyLoaded

private bool $companyLoaded = false

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

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

render()

public render([string $style = 'Hero' ]) : void
Parameters
$style : string = 'Hero'

renderAboutMedia()

Composition of gallery photos for the "about us" section (items 1+2, the hero is 0).

public renderAboutMedia() : void

renderContact()

Footer contact column: address, phone, e-mail.

public renderContact() : void

renderCopyright()

Footer copyright row: year + company name.

public renderCopyright() : void

renderFooterBrand()

Footer brand: logo, name and perex of the company.

public renderFooterBrand() : void

renderGallery()

Strip of profile gallery photos (items 4+): the "gallery" section of the home page.

public renderGallery() : void

renderHero()

Intro block of the home page.

public renderHero() : void

renderPortrait()

Portrait for the "quote" section of the red law-firm theme.

public renderPortrait() : void

Takes the hero photo (gallery item 0); the Hero style does not use it on that theme's home page (the hero shows a statue instead), so the photo is not repeated on the page. A copy of renderQualityMedia() with another template and gallery index.

renderQualityMedia()

Gallery photo for the "quality" section (item 3).

public renderQualityMedia() : void

renderTestimonials()

Client ratings: the Base `RatingComponent` over the company thread.

public renderTestimonials() : void

renderTopbar()

Header contact strip: phone, e-mail, today's opening hours.

public renderTopbar() : void

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

createComponentRating()

Client reviews. The thread belongs to the company (`ratingThreadId`) and is created automatically when the company is saved (Api `CompanyManager` self-heal), so it is only taken over here, never created.

protected createComponentRating() : Rating
Return values
Rating

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

loadAsset()

Returns the asset by its scalar FK (`Company` carries no ORM association), or null.

private loadAsset(int|null $assetId) : Asset|null
Parameters
$assetId : int|null
Return values
Asset|null

prepareCompany()

Loads the company + image channels (logo, hero photo) + the profile gallery. Without a presented company `$company` stays null and templates render nothing; on the front end that is a legitimate state (the company is not set up yet), not an error.

private prepareCompany() : void

assetRels.asset is in the includes in addition to the other findPresented() calls (DefaultTrait/OpeningHoursComponent): only this component renders the gallery, the others do not need the whole collection (an extra JOIN).

prepareTodayHours()

Returns the opening hours of today and whether it is open right now.

private prepareTodayHours(Company|null $company) : void

The design's contact strip has a summary like "Mon-Fri 7:00-17:00", which can be composed from arbitrary opening hours only by guessing (what about an exception on Wednesday?), so today is shown instead: more specific and always true. OpeningHoursComponent (style Table) renders the summary of the whole week.

Parameters
$company : Company|null

resolveTranslation()

Returns the company translation in the current language. `LanguageContext::getLang()` returns `int|string|null` (the route can hold an alias) while `getTranslation()` wants an int; without a numeric language the translation is simply not found.

private resolveTranslation(Company|null $company) : object|null
Parameters
$company : Company|null
Return values
object|null
On this page

Search results