CoolCMS API

MessagePresenter extends BasePresenter
in package
uses PaginationTrait, MessageInitTrait, MessageListTrait, MessageDetailTrait, MessageConfirmTrait, MessageFavListTrait, FavouriteHandlerTrait, MessageFormTrait, MessageGuestEditTrait, CategoryTrait, UserInitTrait

FinalYes

Table of Contents

Constants

DEFAULT_URL_PARAMS  : mixed = [ 'page' => null, 'view' => null, 'order' => nu...
URL state reset for a link that starts a new flow (e.g. "Add advert" from a list).
DEFUALT_URL_PARAMS  : mixed = self::DEFAULT_URL_PARAMS
IDENTITY_LOCALIZED_KEYS  : mixed = ['site.name', 'site.tagline']
Text identity keys that have language variants `<key>.<alias>`.
SESSION_NAMESPACE  : mixed = 'front'
FALLBACK_LAYOUT  : mixed = '@layout_one.latte'
Layout used when the theme lacks the requested one.
guestEditSessionExpiration  : int = 7200
Length of the edit session opened by the link, in seconds (same as an advert after the password).
guestEditSessionSection  : string = 'front.discussion.message.edit'
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.
LIST_INCLUDES  : mixed = ['asset', 'categories.translations', 'commentTh...
Includes of the list, the same for the plain DB path and the search endpoint. The post image is `asset`; there is no `image` association.
LOCALE_MAP  : mixed = ['cs' => 'cs_CZ', 'en' => 'en_US', 'sk' => 'sk_...
Maps the short language code to the full locale of the registered NEON sources.

Properties

$accessTokenValidator  : AccessTokenValidator
Validates access tokens beyond signature and expiry.
$accountDeletionSessionManager  : AccountDeletionSessionManager
Account deletion — cancel ticket of a sign-in refused while the account awaits deletion.
$advertLinksConfig  : AdvertLinksConfig
$authManager  : AuthManager
$authStorageManager  : AuthStorageManager
$capabilityTokenIssuer  : CapabilityTokenIssuer
Issuer of the capability token for the Api layer (see {@see self::hasGuestEditAccess()}).
$categorySlugTranslator  : CategoryNameTranslator
Router translator, the same one that builds the slug from the id in links (see init below).
$container  : Container
$currencyContext  : CurrencyContext
$currencyManager  : CurrencyManager
$deviceDetector  : DeviceDetector
$displayPaymentRegionManager  : PaymentRegionManager
IMPORTANT: a custom name, not `$paymentRegionManager`. Several presenters (Discussion/Bazaar Payment) have the region manager in the constructor, and a same-named property would break the container ("Cannot redeclare").
$eventDispatcher  : EventDispatcher
$googleIntegrations  : GoogleIntegrations
Google services from the third-party connections, used in the page head (`analytics.latte` templates).
$id  : int
$identityAssetManager  : AssetManager
$jwtManager  : JwtManager
$languageContext  : LanguageContext
$languageManager  : LanguageManager
$linksPaymentItemManager  : PaymentItemManager
$localizationContext  : LocalizationContext
$localizationManager  : LocalizationManager
$loginDeviceCookie  : LoginDeviceCookie
"Known device" cookie for the password login throttle ({@see self::rememberLoginDevice()}).
$messageFormFactory  : MessageFormFactory
$messageInfoLineFactory  : MessageInfoLineFactory
$modalWindowsFactory  : ModalWindowsFactory
$name  : string|null
$pageManager  : PageManager
$presenterContext  : PresenterContext
$reCaptchaRuntime  : ReCaptchaRuntime
Decides at runtime whether forms use reCAPTCHA (configuration plus the connection set up in the admin).
$routerDispatcher  : RouterDispatcher
$securityConfig  : SecurityConfig
reCAPTCHA switch for templates (`$reCaptchaEnabled` in the `scripts.latte` templates).
$settingContext  : SettingContext
$settingManager  : SettingManager
$siteBaseUrl  : SiteBaseUrl
Website address for links outside the request; public because components use it (`MessageInfoLine`).
$slug  : string|int|null
$themeContext  : ThemeContext
$themeManager  : ThemeManager
$themeResolver  : DefaultThemeResolver
$translator  : ITranslator
$translatorSessionResolver  : Session
$userManager  : UserManager
$debugMode  : bool
$metaData  : MetaDataDTO|null
$ogData  : OgDataDTO|null
$pageEntity  : Page|null
$productionMode  : bool
$siteIdentity  : SiteIdentityDto|null
$translatorDomain  : string
$categoryManager  : CategoryManager
$currentCategory  : Category|null
$esSearcher  : EsSearcher
$favouriteSessionSection  : string
$favouriteSnippets  : array<int, string>
$fromEs  : bool
True when order and `totalCount` come from Elasticsearch (relevance).
$isLoggingIn  : bool
$message  : Message|null
$messageManager  : MessageManager
$messages  : array<string|int, Message>
$profiles  : array<int, PublicProfile>
$searchHighlights  : array<int, array<string, string>>
$socialsShareFactory  : SocialsShareFactory
$theme  : Theme|null

Methods

__construct()  : mixed
actionAdd()  : void
actionDetail()  : void
actionEdit()  : void
Edit of a post: the logged-in author, or a guest author with an edit session opened by the "Manage post" link from the insert e-mail ({@see MessageGuestEditTrait}).
actionFavouriteList()  : void
actionHomepage()  : void
actionList()  : void
addFavouriteSnippets()  : void
beforeRender()  : void
completeExternalLogin()  : bool
Completes an OAuth login (`LoginExternalComponent`) with the same storage as a password login.
createComponent()  : IComponent|null
createComponentSocialsShare()  : SocialsShare
formatLayoutTemplateFiles()  : array<string|int, mixed>
Returns candidate layout files; Nette takes the first existing one.
getContainer()  : Container
getCurrentCategory()  : Category|null
getDefaultUrlParams()  : array<string, null>
getFavouriteSnippets()  : array<int, string>
getMessage()  : Message|null
getPageEntity()  : Page|null
getRouterDispatcher()  : RouterDispatcher
getTranslator()  : ITranslator
handleAddToFavourites()  : void
handleChangeLocale()  : void
handleConfirm()  : void
Confirms the post by the key from the e-mail link.
handleDelFromFavourites()  : void
handleLogout()  : void
handleSignOut()  : void
Sign-out from an ordinary link (account menu), also without JavaScript.
hasServiceByType()  : bool
Returns whether the container has a service of the given type.
initCurrentCategory()  : void
initFavourites()  : void
initializeTranslator()  : void
initUser()  : void
loadModalWindowComponent()  : void
loginWithCredentials()  : void
Logs in by username and password; called only by the login form (after validation and CSRF).
paginationInit()  : Paginator|null
prepareUserForDetail()  : void
prepareUserForList()  : void
redirectToPendingAccountDeletion()  : void
Account deletion: a sign-in (password or OAuth) was refused because the account awaits deletion: keep the cancel ticket in the session and go to the "Account deletion" page, which offers "Cancel the deletion". Without a ticket (should not happen) the visitor gets the plain refusal flash instead.
renderAdd()  : void
renderDetail()  : void
renderEdit()  : void
renderFavouriteList()  : void
renderList()  : void
requirePagination()  : Paginator
Works like `paginationInit()`, but the paginator is required; a missing component is a wiring error.
setConfigParameters()  : void
setFavouritesForTemplate()  : void
setFavouriteSnippets()  : void
setTranslator()  : $this
startup()  : void
typedComponent()  : T
Returns a subcomponent with a verified type.
buildSiteIdentity()  : SiteIdentityDto
checkAuthentication()  : void
createComponentFrontSystemModalWindows()  : ModalWindows
createComponentMessageForm()  : MessageForm
createComponentMessageInfoLine()  : Multiplier<string|int, MessageInfoLine>
currentAbsoluteUrl()  : string
Returns `link('//this')`, or the request address without query when it cannot be built.
fallbackToMainLocalization()  : bool
Whether the presenter may fall back to the main localization for an unknown locale; a regular page may not (404).
getFavouriteIds()  : array<int, int>
getFavouriteSessionStorage()  : Session
getSessionKey()  : string
Returns a session key string, e.g. 'front.auth.step1'.
getSessionSection()  : SessionSection
Returns a Nette\SessionSection instance using a dynamically built session key.
initializeMetaData()  : void
initializeOgData()  : void
initializePresenterContext()  : void
initSiteIdentity()  : void
isSameSiteRequest()  : bool
Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.
loadPageEntity()  : Page|null
Returns the page of the request by `slug` (empty is the home page, a number is the ID, otherwise `href`).
logout()  : void
metaData()  : MetaDataDTO
Returns the page meta data; filled by startup, an empty DTO before that.
ogData()  : OgDataDTO
Returns the page OG data; filled by `initializeOgData()` in startup, an empty DTO before that.
prepareMetaData()  : MetaDataDTO
prepareOgData()  : OgDataDTO
setTranslatorDomain()  : void
buildDefaultOgImage()  : OgImageDTO|null
Builds the default OG image from the site identity (admin, settings, site identity).
collectMessageVisibilityIssues()  : array<int, string>
Returns the reasons why the post is not publicly visible; an empty array means the post is fine.
createIdentity()  : SimpleIdentity|null
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).
expireIdleLogin()  : bool
Checks whether the login expired from inactivity.
formatLayoutCandidates()  : array<int, string>
getClientIp()  : string
getFavouriteSection()  : SessionSection
grantMessageEditCapability()  : void
The token is minted again on every request from the verified session state and never stored.
grantMessageEditCapabilityFromSession()  : void
Issues the capability from the session before the post is loaded, so `get` for editing returns the guest's own e-mail unmasked. The Api verifies it itself (fingerprint of the secret from the DB), so a stale session row opens nothing; {@see self::hasGuestEditAccess()} stays decisive for access.
guestEditAccess()  : AdvertAccessSession
hasGuestEditAccess()  : bool
Returns whether this visitor holds a valid edit session for the post. The session row must match the secret of the post loaded from the DB and must not be expired; otherwise it is revoked.
hasPaidLinks()  : bool
True when the message has an active, valid item of the "Show links" tariff (`AdvertLinksConfig`, default 4): the text then shows its web addresses as links.
hideMessageDetail()  : 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).
initializeDisplayRegion()  : void
Initializes the currency and VAT display of prices.
initializeExternalFiles()  : void
initializeMetaTags()  : void
initializePage()  : void
isCategoryBranchActive()  : bool
Whether the category and all its ancestors are active (nested set: an ancestor encloses lft/rgt).
isDevelopment()  : bool
isEntityInFavourites()  : bool
isMessageAuthor()  : bool
Author is the logged-in user who inserted the post (an anonymous post has no author password).
isMessageEditor()  : bool
The logged-in author edits their post; a guest post only with a valid edit session from the link.
layoutFileExists()  : bool
loadIdentityAssets()  : array<int, Asset>
Loads the identity assets by id, keyed by id.
loadLocalization()  : Localization|null
Returns the localization by `loc` from the URL, or `null` when there is no such locale.
localizationCurrencyKey()  : string|null
Front needs no currency key from the localization; the currency and the display region are filled by {@see CurrencyInitTrait::initializeDisplayRegion()}.
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.
logoutNetteUser()  : void
prepareCanonicalUrl()  : void
prepareCategoryFilter()  : void
prepareFilters()  : array<int, Filter>
prepareImageGallery()  : void
prepareMessageSearchFilter()  : Filter
Full-text search through Elasticsearch (ids go to `SearchIdFilter`; visibility, level and pagination stay in the DB phase 1). When Elasticsearch is disabled, down or the query is short, it transparently falls back to MySQL `MATCH_AGAINST` over subject and text.
prepareOgDataForDetail()  : void
prepareOgDataForList()  : void
prepareOrderBy()  : array<string, bool>
preparePerPage()  : int
prepareView()  : void
processFailedLogin()  : void
processInvalidToken()  : void
processLogin()  : void
processLoginException()  : void
processMissingToken()  : void
processSuccessfulLogin()  : void
processValidToken()  : void
readLoginDeviceToken()  : string|null
Returns the raw known-device cookie for the Api login (the Api verifies its signature).
redeemManageKeyFromLink()  : void
Handles the "Manage post" link: a valid key opens the edit session, an invalid or expired one gives a message (the edit then ends on "permission denied"). Redirects without the key either way.
redirectAfterLoginAction()  : void
Ends a sign-in attempt. A classic (non-AJAX) successful sign-in lands on "My account" ({@see PageId::SYSTEM_USER_ACCOUNT}); a failed one on the home page. An AJAX sign-in stays on the current page and only redraws the flash messages.
refreshNetteIdentity()  : bool
Refreshes the token for the same logged-in user.
rememberLoginDevice()  : void
Issues or renews the "known device" cookie after a successful login (password or OAuth).
resolveLoginErrorMessage()  : string
Resolves the translated login error text.
revokeTokensOnLogout()  : void
Calls the Api logout (revokes the refresh family and deny-lists the access `jti`) for the tokens of the current session.
searchViaApi()  : Message>, 1: int, 2: bool, 3: array>}|null
Searches through the Api endpoint `api/discussion/message/search`.
setDefaultAvatar()  : array{rel: mixed}
setNetteUser()  : void
tryRefresh()  : bool
Tries an automatic refresh when the access token has expired.

Constants

DEFAULT_URL_PARAMS

URL state reset for a link that starts a new flow (e.g. "Add advert" from a list).

public mixed DEFAULT_URL_PARAMS = [ 'page' => null, 'view' => null, 'order' => null, 'count' => null, 'cat' => null, 'catId' => null, 'categoryId' => null, 'search' => null, 'slug' => null, 'id' => null, 'tab' => null, 'c' => null, 'filter' => null, 'pr' => null, // Private messages (`MessagePresenter`): without the reset the mailbox and the // unread filter would leak into links outside messages. 'box' => null, 'unread' => null, ]

Nette adds the #[Persistent] parameters of the current request to a link when the target presenter inherits them from the same class, so /inzeraty/automobily would produce /pridat-inzerat/?count=0&categoryId=automobily. An explicit null cancels that: ComponentReflection::saveState() skips a key already present in the parameters, so the global state is not filled in and null drops out of the URL. null is safe even for untyped or non-nullable parameters (public int $id) because the skipped value is never cast.

The list covers all own persistent parameters of front presenters. Parameters declared on this BasePresenter (slug, lang, loc) are carried on purpose and do not belong in the reset, except slug, which the caller always overrides with the page ID.

IMPORTANT: a new #[Persistent] parameter must be added here too; otherwise it leaks into links. Checked by tests/Unit/Core/DefaultUrlParamsCoverageTest.php.

DEFUALT_URL_PARAMS

misspelled name kept for existing callers, use DEFAULT_URL_PARAMS

public mixed DEFUALT_URL_PARAMS = self::DEFAULT_URL_PARAMS

IDENTITY_LOCALIZED_KEYS

Text identity keys that have language variants `<key>.<alias>`.

public mixed IDENTITY_LOCALIZED_KEYS = ['site.name', 'site.tagline']

SESSION_NAMESPACE

protected mixed SESSION_NAMESPACE = 'front'

FALLBACK_LAYOUT

Layout used when the theme lacks the requested one.

private mixed FALLBACK_LAYOUT = '@layout_one.latte'

@layout_one.latte (one column, shared header and footer) exists in every theme and is the plainest page the system can render, so anything fits in it.

IMPORTANT: not @layout.latte; that is a bare Nette skeleton titled "Nette Web" without header, footer or styles, hardly better than a missing layout.

guestEditSessionExpiration

Length of the edit session opened by the link, in seconds (same as an advert after the password).

private int guestEditSessionExpiration = 7200

guestEditSessionSection

private string guestEditSessionSection = 'front.discussion.message.edit'

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

LIST_INCLUDES

Includes of the list, the same for the plain DB path and the search endpoint. The post image is `asset`; there is no `image` association.

private mixed LIST_INCLUDES = ['asset', 'categories.translations', 'commentThread', 'ratingThread']

LOCALE_MAP

Maps the short language code to the full locale of the registered NEON sources.

private mixed LOCALE_MAP = ['cs' => 'cs_CZ', 'en' => 'en_US', 'sk' => 'sk_SK']

The short code (cs, en, sk) comes from LanguageContext, derived from the URL parameter loc/lang; the full locales are cs_CZ, en_US, sk_SK. translator.neon configures one shared fallback chain [cs_CZ, cs, en_US, en, sk_SK, sk] for all languages, so a short code would always map to cs_CZ first, whatever language is active. A direct match on the full locale bypasses that.

The Contributte LocaleResolvers\Router (the only configured resolver) looks for the route parameter locale, but this application routes under loc, so it always returns null and the translator falls back to default: cs. An explicit setLocale() from here bypasses the resolver, which Translator::getLocale() asks only while no locale has been set explicitly.

Properties

$accessTokenValidator

Validates access tokens beyond signature and expiry.

public AccessTokenValidator $accessTokenValidator

A revoked token (jti on the deny-list) that has not expired yet would otherwise keep the session logged in although the Api guard rejects the same token. Same contract as JwtAuthTrait::checkJwtAuth(), one implementation.

Attributes
#[Inject]

$categorySlugTranslator

Router translator, the same one that builds the slug from the id in links (see init below).

public CategoryNameTranslator $categorySlugTranslator
Attributes
#[Inject]

$displayPaymentRegionManager

IMPORTANT: a custom name, not `$paymentRegionManager`. Several presenters (Discussion/Bazaar Payment) have the region manager in the constructor, and a same-named property would break the container ("Cannot redeclare").

public PaymentRegionManager $displayPaymentRegionManager
Attributes
#[Inject]

$googleIntegrations

Google services from the third-party connections, used in the page head (`analytics.latte` templates).

public GoogleIntegrations $googleIntegrations
Attributes
#[Inject]

$loginDeviceCookie

"Known device" cookie for the password login throttle ({@see self::rememberLoginDevice()}).

public LoginDeviceCookie $loginDeviceCookie
Attributes
#[Inject]

$reCaptchaRuntime

Decides at runtime whether forms use reCAPTCHA (configuration plus the connection set up in the admin).

public ReCaptchaRuntime $reCaptchaRuntime
Attributes
#[Inject]

$securityConfig

reCAPTCHA switch for templates (`$reCaptchaEnabled` in the `scripts.latte` templates).

public SecurityConfig $securityConfig
Attributes
#[Inject]

$siteBaseUrl

Website address for links outside the request; public because components use it (`MessageInfoLine`).

public SiteBaseUrl $siteBaseUrl
Attributes
#[Inject]

$slug

public string|int|null $slug = NULL
Attributes
#[Persistent]

$translatorDomain

protected string $translatorDomain = 'front.discussion.presenters.message'

$favouriteSnippets

private array<int, string> $favouriteSnippets = ['favouriteLinksSnippet', 'flashMessagesSnippet']

$fromEs

True when order and `totalCount` come from Elasticsearch (relevance).

private bool $fromEs = false

$searchHighlights

private array<int, array<string, string>> $searchHighlights = []

thread id => field => safe HTML

Methods

actionAdd()

public actionAdd(mixed $slug) : void
Parameters
$slug : mixed

actionDetail()

public actionDetail(string|int|null $slug, int $id, string $loc) : void
Parameters
$slug : string|int|null
$id : int
$loc : string

actionEdit()

Edit of a post: the logged-in author, or a guest author with an edit session opened by the "Manage post" link from the insert e-mail ({@see MessageGuestEditTrait}).

public actionEdit(mixed $slug[, int|null $id = null ]) : void
Parameters
$slug : mixed
$id : int|null = null

actionFavouriteList()

public actionFavouriteList([int $page = 1 ]) : void
Parameters
$page : int = 1

actionHomepage()

public actionHomepage([int $page = 1 ][, string|null $search = null ]) : void
Parameters
$page : int = 1
$search : string|null = null

actionList()

public actionList([int $page = 1 ][, string|null $search = null ][, int $count = 0 ]) : void
Parameters
$page : int = 1
$search : string|null = null
$count : int = 0

addFavouriteSnippets()

public addFavouriteSnippets(array<int, string> $snippets) : void
Parameters
$snippets : array<int, string>

completeExternalLogin()

Completes an OAuth login (`LoginExternalComponent`) with the same storage as a password login.

public completeExternalLogin(array<string, mixed> $resultData) : bool

IMPORTANT: the whole session section is cleared first and the refresh token from the Api must be stored. Otherwise the user drops out after 15 minutes, and the refresh token of the previous account stays in the section, so tryRefresh() would log account A back in after expiry (shared computer).

Parameters
$resultData : array<string, mixed>

data from the Api loginExternal (token, refreshToken, payload)

Return values
bool

createComponent()

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

formatLayoutTemplateFiles()

Returns candidate layout files; Nette takes the first existing one.

public formatLayoutTemplateFiles() : array<string|int, mixed>

IMPORTANT: when the theme lacks the layout, a fallback is added. The layout name is stored in cms_system_pages.layout, one column shared by all themes, so a page set to @text_layout_two.latte wants that file even in a theme that never got it. Without a fallback Nette finds nothing and renders the presenter without a layout: the page has no header, footer or styles but returns HTTP 200.

The fallback is logged, because a silent fallback would hide the problem entirely; when the page asks for the fallback layout itself and the theme lacks it, there is nowhere to fall back to, so it is logged as an error and the page renders without a layout.

Return values
array<string|int, mixed>

getContainer()

public getContainer() : Container
Return values
Container

getDefaultUrlParams()

public getDefaultUrlParams() : array<string, null>
Return values
array<string, null>

getFavouriteSnippets()

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

handleAddToFavourites()

public handleAddToFavourites(int $entityId[, string $style = 'Style_1' ]) : void
Parameters
$entityId : int
$style : string = 'Style_1'

handleChangeLocale()

public handleChangeLocale(string $locale) : void
Parameters
$locale : string

handleConfirm()

Confirms the post by the key from the e-mail link.

public handleConfirm() : void

IMPORTANT: Nette forces Requires(sameOrigin: true) on every handle*(), and a click from a mail client is cross-site (Sec-Fetch-Site: none), so the handler would silently not run. The link is protected by the key, not by the origin, hence #[CrossOrigin]. An unconfirmed post is hidden from anonymous users (actionDetail() nulls $this->message), so the handler works only with the id from the URL.

The Api action confirmByKey verifies the key, writes and applies the limit (five layers, so an internal bridge; ConfirmByKeyTrait). The response does not distinguish an unknown post from a wrong key, and the front end does not either (one error message). Repeating the click with the right key is a success.

Attributes
#[CrossOrigin]

handleDelFromFavourites()

public handleDelFromFavourites(int $entityId[, string $style = 'Style_1' ]) : void
Parameters
$entityId : int
$style : string = 'Style_1'

handleSignOut()

Sign-out from an ordinary link (account menu), also without JavaScript.

public handleSignOut() : void

Nette refuses every signal whose request is not same-origin (Sec-Fetch-Site) and redirects to the same URL without do, so a typed or bookmarked ?do=signOut (Sec-Fetch-Site: none) never ran. A user-initiated navigation cannot be forged by another site, so it is allowed here as well; a cross-site request still ends in detectedCsrf().

Attributes
#[Requires]
$sameOrigin: false

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

initFavourites()

public initFavourites(string $sessionSection) : void
Parameters
$sessionSection : string

initializeTranslator()

public initializeTranslator(string|null $alias) : void
Parameters
$alias : string|null

loadModalWindowComponent()

public loadModalWindowComponent() : void

loginWithCredentials()

Logs in by username and password; called only by the login form (after validation and CSRF).

public loginWithCredentials(string $username, string $password[, bool $remember = false ]) : void

IMPORTANT: this must not be a handle* method. Nette finds signals by that prefix, so a public handleLogin() would be a signal on every presenter (?do=login&username=…&password=…): the password could end up in the URL and the server log, and the form token would be bypassed.

Parameters
$username : string
$password : string
$remember : bool = false

redirectToPendingAccountDeletion()

Account deletion: a sign-in (password or OAuth) was refused because the account awaits deletion: keep the cancel ticket in the session and go to the "Account deletion" page, which offers "Cancel the deletion". Without a ticket (should not happen) the visitor gets the plain refusal flash instead.

public redirectToPendingAccountDeletion(mixed $resultData) : void
Parameters
$resultData : mixed

renderAdd()

public renderAdd(string|int $slug) : void
Parameters
$slug : string|int

renderDetail()

public renderDetail(string|int|null $slug, int $id, string $loc) : void
Parameters
$slug : string|int|null
$id : int
$loc : string

renderEdit()

public renderEdit(mixed $slug[, int|null $id = null ]) : void
Parameters
$slug : mixed
$id : int|null = null

renderFavouriteList()

public renderFavouriteList([int $page = 1 ]) : void
Parameters
$page : int = 1

renderList()

public renderList([int $page = 1 ][, string|null $search = null ]) : void
Parameters
$page : int = 1
$search : string|null = null

requirePagination()

Works like `paginationInit()`, but the paginator is required; a missing component is a wiring error.

public requirePagination(int $perPage) : Paginator
Parameters
$perPage : int
Return values
Paginator

setConfigParameters()

public setConfigParameters([bool $debugMode = false ][, bool $productionMode = false ]) : void
Parameters
$debugMode : bool = false
$productionMode : bool = false

setFavouritesForTemplate()

public setFavouritesForTemplate(int $id) : void
Parameters
$id : int

setFavouriteSnippets()

public setFavouriteSnippets(array<int, string> $snippets) : void
Parameters
$snippets : array<int, string>

setTranslator()

public setTranslator(ITranslator $translator) : $this
Parameters
$translator : ITranslator
Return values
$this

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

currentAbsoluteUrl()

Returns `link('//this')`, or the request address without query when it cannot be built.

protected currentAbsoluteUrl() : string

IMPORTANT: it is called from startup() of every front page (MetaDataInitTrait, OgDataInitTrait), before Nette verifies the required action parameters. A request without them (/editace-firmy without id for actionEdit(int $id)) should end as a 404, but link('//this') reports an invalid link there; in debug mode that is an E_USER_WARNING which Tracy (strict mode) turns into a 500 that catch cannot catch. So InvalidLinkException is forced for the duration of the call and the mode is restored in finally (same principle as SafeLinkExtension::generateSafeLink(), which cannot handle the //this target because it verifies that the target presenter exists).

Return values
string

fallbackToMainLocalization()

Whether the presenter may fall back to the main localization for an unknown locale; a regular page may not (404).

protected fallbackToMainLocalization() : bool
Return values
bool

getFavouriteIds()

protected getFavouriteIds() : array<int, int>
Return values
array<int, int>

getFavouriteSessionStorage()

protected getFavouriteSessionStorage() : Session
Return values
Session

getSessionKey()

Returns a session key string, e.g. 'front.auth.step1'.

protected getSessionKey([string|null $namespace = null ][, string|null $subsection = null ], string ...$extra) : string
Parameters
$namespace : string|null = null

Base namespace (module prefix). Uses SESSION_NAMESPACE if null.

$subsection : string|null = null

Subsection under the namespace. Uses SESSION_SUBSECTION constant if null.

$extra : string

Additional parts to append (e.g. 'step1', 'wizard', etc.).

Return values
string

getSessionSection()

Returns a Nette\SessionSection instance using a dynamically built session key.

protected getSessionSection([string|null $namespace = null ][, string|null $subsection = null ], string ...$extra) : SessionSection
Parameters
$namespace : string|null = null
$subsection : string|null = null
$extra : string
Tags
see
getSessionKey()
Return values
SessionSection

isSameSiteRequest()

Tells whether the request comes from the own site (Nette SameSite cookie); protects GET actions with a side effect.

protected isSameSiteRequest() : bool

getHttpRequest() returns the IRequest interface, while isSameSite() exists only on Nette\Http\Request.

Return values
bool

loadPageEntity()

Returns the page of the request by `slug` (empty is the home page, a number is the ID, otherwise `href`).

protected loadPageEntity() : Page|null

Returns null when the page does not exist; the 404 is decided by BasePresenter::startup(). The error page (ErrorPresenter) overrides the method because it has no page in the DB and the layout needs an entity.

Return values
Page|null

ogData()

Returns the page OG data; filled by `initializeOgData()` in startup, an empty DTO before that.

protected ogData() : OgDataDTO
Return values
OgDataDTO

buildDefaultOgImage()

Builds the default OG image from the site identity (admin, settings, site identity).

private buildDefaultOgImage(string $alt) : OgImageDTO|null

Default only: detail pages override the image with their own (OgDataTrait::prepareOgDataForDetail()), after this call. Without a configured image og:image is not rendered at all.

Parameters
$alt : string
Return values
OgImageDTO|null

collectMessageVisibilityIssues()

Returns the reasons why the post is not publicly visible; an empty array means the post is fine.

private collectMessageVisibilityIssues(Message $message) : array<int, string>

Keys are the translations notices.hidden.<key>.

Parameters
$message : Message
Return values
array<int, string>

createIdentity()

private createIdentity(array<string, mixed> $payload, string $token) : SimpleIdentity|null
Parameters
$payload : array<string, mixed>
$token : string
Return values
SimpleIdentity|null

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

expireIdleLogin()

Checks whether the login expired from inactivity.

private expireIdleLogin(AuthSessionStorage $authStorage) : bool

If so, it revokes the tokens (like a logout), clears the auth section, logs out the Nette identity and returns true; otherwise it moves the activity stamp. The limit is 30 minutes without "remember me", 31 days with it (AuthSessionStorage::isIdleExpired()).

Parameters
$authStorage : AuthSessionStorage
Return values
bool

formatLayoutCandidates()

private formatLayoutCandidates(Theme $theme, string $layout) : array<int, string>
Parameters
$theme : Theme
$layout : string
Return values
array<int, string>

getFavouriteSection()

private getFavouriteSection() : SessionSection
Return values
SessionSection

grantMessageEditCapability()

The token is minted again on every request from the verified session state and never stored.

private grantMessageEditCapability(int $messageId, string $secret, int $expiration) : void
Parameters
$messageId : int
$secret : string
$expiration : int

grantMessageEditCapabilityFromSession()

Issues the capability from the session before the post is loaded, so `get` for editing returns the guest's own e-mail unmasked. The Api verifies it itself (fingerprint of the secret from the DB), so a stale session row opens nothing; {@see self::hasGuestEditAccess()} stays decisive for access.

private grantMessageEditCapabilityFromSession(int $messageId) : void
Parameters
$messageId : int

hasGuestEditAccess()

Returns whether this visitor holds a valid edit session for the post. The session row must match the secret of the post loaded from the DB and must not be expired; otherwise it is revoked.

private hasGuestEditAccess(Message $message) : bool

IMPORTANT: the capability is issued only after the comparison with the fresh secret, so changing it revokes every open edit session at once.

Parameters
$message : Message
Return values
bool

True when the message has an active, valid item of the "Show links" tariff (`AdvertLinksConfig`, default 4): the text then shows its web addresses as links.

private hasPaidLinks(Message $message) : bool
Parameters
$message : Message
Return values
bool

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
string

identitySettingOrNull()

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

initializeDisplayRegion()

Initializes the currency and VAT display of prices.

private initializeDisplayRegion() : void

IMPORTANT: the display region is the payment region of the localization. The currency column of the localization is not read and ?curr= from the URL is ignored on the front end; the only source is DisplayRegionResolver. The cart and checkout may switch the region by the customer's choice (CheckoutRegionTrait), the catalog always shows the localization region.

Call it after initializeCurrencyList() (the resolver needs the currencies).

initializeExternalFiles()

private initializeExternalFiles(Page|null $pageEntity) : void
Parameters
$pageEntity : Page|null

initializeMetaTags()

private initializeMetaTags(Page|null $pageEntity) : void
Parameters
$pageEntity : Page|null

isCategoryBranchActive()

Whether the category and all its ancestors are active (nested set: an ancestor encloses lft/rgt).

private isCategoryBranchActive(Category $category) : bool
Parameters
$category : Category
Return values
bool

isEntityInFavourites()

private isEntityInFavourites(int $entityId) : bool
Parameters
$entityId : int
Return values
bool

isMessageAuthor()

Author is the logged-in user who inserted the post (an anonymous post has no author password).

private isMessageAuthor(Message $message) : bool
Parameters
$message : Message
Return values
bool

isMessageEditor()

The logged-in author edits their post; a guest post only with a valid edit session from the link.

private isMessageEditor(Message $message) : bool
Parameters
$message : Message
Return values
bool

layoutFileExists()

private layoutFileExists(array<int, string> $files) : bool
Parameters
$files : array<int, string>
Return values
bool

loadIdentityAssets()

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>

loadLocalization()

Returns the localization by `loc` from the URL, or `null` when there is no such locale.

private loadLocalization() : Localization|null

IMPORTANT: an unknown locale must return null (a non-null return type would turn a forged prefix such as /xx/ into a TypeError, HTTP 500). BasePresenter::startup() turns null into a 404; the error page takes the main website localization via fallbackToMainLocalization().

Return values
Localization|null

localizationCurrencyKey()

Front needs no currency key from the localization; the currency and the display region are filled by {@see CurrencyInitTrait::initializeDisplayRegion()}.

private localizationCurrencyKey(object $localization) : string|null
Parameters
$localization : object
Return values
string|null

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
Return values
string

prepareCategoryFilter()

private prepareCategoryFilter(array<int, Filter> &$filters) : void
Parameters
$filters : array<int, Filter>

prepareFilters()

private prepareFilters([string|null $search = null ][, array<string|int, int>|null $messageIds = null ]) : array<int, Filter>
Parameters
$search : string|null = null
$messageIds : array<string|int, int>|null = null
Return values
array<int, Filter>

prepareMessageSearchFilter()

Full-text search through Elasticsearch (ids go to `SearchIdFilter`; visibility, level and pagination stay in the DB phase 1). When Elasticsearch is disabled, down or the query is short, it transparently falls back to MySQL `MATCH_AGAINST` over subject and text.

private prepareMessageSearchFilter(string $search) : Filter

Message has no language: one global index, the language alias is null.

Parameters
$search : string
Return values
Filter

prepareOrderBy()

private prepareOrderBy() : array<string, bool>
Return values
array<string, bool>

preparePerPage()

private preparePerPage(int $count[, int $defaultCount = 20 ]) : int
Parameters
$count : int
$defaultCount : int = 20
Return values
int

processLogin()

private processLogin(string $username, string $password[, bool $remember = false ]) : void
Parameters
$username : string
$password : string
$remember : bool = false

processLoginException()

private processLoginException(Exception $e) : void
Parameters
$e : Exception

readLoginDeviceToken()

Returns the raw known-device cookie for the Api login (the Api verifies its signature).

private readLoginDeviceToken() : string|null
Return values
string|null

Handles the "Manage post" link: a valid key opens the edit session, an invalid or expired one gives a message (the edit then ends on "permission denied"). Redirects without the key either way.

private redeemManageKeyFromLink(int $messageId) : void
Parameters
$messageId : int

redirectAfterLoginAction()

Ends a sign-in attempt. A classic (non-AJAX) successful sign-in lands on "My account" ({@see PageId::SYSTEM_USER_ACCOUNT}); a failed one on the home page. An AJAX sign-in stays on the current page and only redraws the flash messages.

private redirectAfterLoginAction([bool $succeeded = false ]) : void
Parameters
$succeeded : bool = false

refreshNetteIdentity()

Refreshes the token for the same logged-in user.

private refreshNetteIdentity(array<string, mixed> $payload, string $token) : bool

The identity data (token, name, email) are overwritten in the stored object without login(), so neither the session ID nor the form CSRF tokens change. The identity lives in the session section as an object and the change is written at the end of the request.

Parameters
$payload : array<string, mixed>
$token : string
Return values
bool —

false when not possible (nobody logged in or another user), the caller then uses login

rememberLoginDevice()

Issues or renews the "known device" cookie after a successful login (password or OAuth).

private rememberLoginDevice(mixed $payload) : void

The cookie (LoginDeviceCookie) is a signed proof that this browser has already logged in to the account. The next login sends it to the Api (self::processLogin()), so above the account limit the password from this browser is still verified and foreign attempts do not lock the owner out. HttpOnly, SameSite=Lax, Secure on HTTPS; lifetime ratelimit.loginDevice.cookieLifetime.

Parameters
$payload : mixed

resolveLoginErrorMessage()

Resolves the translated login error text.

private resolveLoginErrorMessage(Result $result) : string

IMPORTANT: a throttle by the brute-force gate must not be shown as "wrong password"; the limit would then look like an inexplicably failing form. The generic results.rateLimitExceeded carries no seconds and does not belong to login, so the login flow has its own key login.rateLimit.message (same family as front.general.login.error.message), with the seconds passed as %count% (Contributte: numeric second argument).

The Api sends retryAfter in data (AuthPresenter::rateLimitedResult()); the internal bridge call does not see the Retry-After header.

Parameters
$result : Result
Return values
string

revokeTokensOnLogout()

Calls the Api logout (revokes the refresh family and deny-lists the access `jti`) for the tokens of the current session.

private revokeTokensOnLogout(AuthSessionStorage $authStorage, mixed $userId) : void

Deliberately fail-open: any failure is only logged, because the local logout must not stay unfinished.

Parameters
$authStorage : AuthSessionStorage
$userId : mixed

searchViaApi()

Searches through the Api endpoint `api/discussion/message/search`.

private searchViaApi(string $search, bool $orderChosen, Paginator|null $paginator) : Message>, 1: int, 2: bool, 3: array>}|null

Three states:

  • (a) search without a manual sort choice: orderBys = null, Elasticsearch sorts and paginates by score (fromEs: true); the DB keeps visibility.
  • (b) search with a manual choice (/o-N): orderBys from prepareOrderBy(), the DB sorts, paginates and counts over the Elasticsearch id set.
  • (c) without a search this path is never reached; nothing changes.

IMPORTANT: deliberate deviation: in state (a) the precedence of topped threads does not apply. prepareOrderBy() normally puts topedUntil > NOW() first, but Elasticsearch composes the relevance page.

null means use the plain DB path (deny, bridge outage or Elasticsearch unavailable).

Parameters
$search : string
$orderChosen : bool
$paginator : Paginator|null
Return values
Message>, 1: int, 2: bool, 3: array>}|null

setDefaultAvatar()

private setDefaultAvatar() : array{rel: mixed}
Return values
array{rel: mixed} —

rel = URL of the default avatar from the noAvatarImg setting

setNetteUser()

private setNetteUser(array<string, mixed>|null $payload, string $token) : void
Parameters
$payload : array<string, mixed>|null
$token : string

tryRefresh()

Tries an automatic refresh when the access token has expired.

private tryRefresh(AuthSessionStorage $authStorage) : bool

If the session holds a refresh token and the Api accepts it, the new pair is stored in the session and true is returned; otherwise false, and the caller drops the session.

Parameters
$authStorage : AuthSessionStorage
Return values
bool
On this page

Search results