CoolCMS API

InitTrait

Table of Contents

Properties

$company  : Company|null
Presented company; loaded once per request (`createComponentRating` calls it too).
$companyLoaded  : bool

Methods

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.

Properties

$company

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

private Company|null $company = null

$companyLoaded

private bool $companyLoaded = false

Methods

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