MessagePresenter
extends BasePresenter
in package
uses
MessageInitTrait, MessageListTrait, MessageDetailTrait, MessageReplyFormTrait
Messages: the mailbox of the logged-in user.
IMPORTANT: a thread is not created from here. A conversation always starts from an action (today a reply to an advert in Bazaar/Comcat), never from a free "write to anyone"; this presenter only reads conversations, replies to them and hides them.
IMPORTANT: userId is never passed. The server sets the scope from the JWT in the Api action
(see MessageThreadPresenter::internalActionMyThreads());
from here only "which mailbox I want to see" goes out.
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
- DETAIL_SLUG : mixed = \App\Core\Routers\PageId::BASE_MESSAGE_DETAIL
- Slug of the conversation detail page.
- IDENTITY_LOCALIZED_KEYS : mixed = ['site.name', 'site.tagline']
- Text identity keys that have language variants `<key>.<alias>`.
- LIST_SLUG : mixed = \App\Core\Routers\PageId::BASE_MESSAGE_LIST
- Slug of the conversation list page (fixed id, project convention).
- SESSION_NAMESPACE : mixed = 'front'
- FALLBACK_LAYOUT : mixed = '@layout_one.latte'
- Layout used when the theme lacks the requested one.
- 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.
- 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.
- $authManager : AuthManager
- $authStorageManager : AuthStorageManager
- $box : string
- Mailbox: `received` / `sent`; empty means both.
- $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).
- $identityAssetManager : AssetManager
- $jwtManager : JwtManager
- $languageContext : LanguageContext
- $languageManager : LanguageManager
- $localizationContext : LocalizationContext
- $localizationManager : LocalizationManager
- $loginDeviceCookie : LoginDeviceCookie
- "Known device" cookie for the password login throttle ({@see self::rememberLoginDevice()}).
- $modalWindowsFactory : ModalWindowsFactory
- $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
- $unread : bool
- Show only conversations with an unread message.
- $userManager : UserManager
- $debugMode : bool
- $metaData : MetaDataDTO|null
- $ogData : OgDataDTO|null
- $pageEntity : Page|null
- $productionMode : bool
- $siteIdentity : SiteIdentityDto|null
- $translatorDomain : string
- $isLoggingIn : bool
- $messageManager : MessageManager
- $messageParticipantManager : MessageParticipantManager
- $messageThreadManager : MessageThreadManager
- $newMessageIds : array<int, true>
- $openedThread : MessageThread|null
- $participantViews : array<int, MessageParticipantView>
- $readMessageIds : array<int, true>
- $systemEvents : array<int, array{event: string, name: string}>
- $theme : Theme|null
- $threadMessages : array<int, Message>
Methods
- __construct() : mixed
- actionDetail() : void
- actionList() : void
- beforeRender() : void
- completeExternalLogin() : bool
- Completes an OAuth login (`LoginExternalComponent`) with the same storage as a password login.
- createComponent() : IComponent|null
- formatLayoutTemplateFiles() : array<string|int, mixed>
- Returns candidate layout files; Nette takes the first existing one.
- getContainer() : Container
- getDefaultUrlParams() : array<string, null>
- getPageEntity() : Page|null
- getRouterDispatcher() : RouterDispatcher
- getTranslator() : ITranslator
- handleChangeLocale() : void
- handleHide() : void
- "Delete for me": the thread stays for the other party.
- handleLogout() : void
- handleSignOut() : void
- Sign-out from an ordinary link (account menu), also without JavaScript.
- handleSwitchBox() : void
- Switches the mailbox without reloading the whole page.
- hasServiceByType() : bool
- Returns whether the container has a service of the given type.
- initializeTranslator() : void
- loadModalWindowComponent() : void
- loginWithCredentials() : void
- Logs in by username and password; called only by the login form (after validation and CSRF).
- onReplySuccess() : 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.
- renderDetail() : void
- renderList() : void
- setConfigParameters() : void
- setTranslator() : $this
- startup() : void
- typedComponent() : T
- Returns a subcomponent with a verified type.
- buildSiteIdentity() : SiteIdentityDto
- checkAuthentication() : void
- createComponentFrontSystemModalWindows() : ModalWindows
- createComponentReplyForm() : Form
- 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).
- 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
- resolveBox() : MessageBox|null
- Mailbox from the persistent parameter; `null` means both (received and sent).
- setTranslatorDomain() : void
- buildDefaultOgImage() : OgImageDTO|null
- Builds the default OG image from the site identity (admin, settings, site identity).
- buildSystemEvents() : array<int, array{event: string, name: string}>
- Builds the system messages "X joined / left the conversation". The message text in the DB is a code (see {@see MessageSystemEvent}); the sentence is composed here from the translation and the participant's current name (also a former one, the Api still returns the row).
- collectGuestContacts() : array<int, MessageParticipantView>
- Returns contacts of participants without an account: the only way to reply to an `email_only` thread.
- 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.
- findMyParticipantRow() : MessageParticipant|null
- My participant row (`myList`, the caller's only); carries `last_read_datetime` and the counter.
- formatLayoutCandidates() : array<int, string>
- getClientIp() : string
- getCurrentUserId() : int|null
- 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).
- indexById() : array<int, MessageParticipantView>
- initConversation() : void
- Loads messages and participants (other party's name, guest contact) and counts new messages.
- initializeDisplayRegion() : void
- Initializes the currency and VAT display of prices.
- initializeExternalFiles() : void
- initializeMetaTags() : void
- initializePage() : void
- isDevelopment() : bool
- 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.
- loadMyParticipantsByThread() : array<int, MessageParticipant>
- Returns my participant rows by thread; they carry unread, role and archive.
- loadThread() : MessageThread|null
- 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
- 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).
- 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).
- requireLoggedUser() : int
- 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.
- 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
DETAIL_SLUG
Slug of the conversation detail page.
public
mixed
DETAIL_SLUG
= \App\Core\Routers\PageId::BASE_MESSAGE_DETAIL
IDENTITY_LOCALIZED_KEYS
Text identity keys that have language variants `<key>.<alias>`.
public
mixed
IDENTITY_LOCALIZED_KEYS
= ['site.name', 'site.tagline']
LIST_SLUG
Slug of the conversation list page (fixed id, project convention).
public
mixed
LIST_SLUG
= \App\Core\Routers\PageId::BASE_MESSAGE_LIST
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.
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
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]
$accountDeletionSessionManager
Account deletion — cancel ticket of a sign-in refused while the account awaits deletion.
public
AccountDeletionSessionManager
$accountDeletionSessionManager
Attributes
- #[Inject]
$authManager
public
AuthManager
$authManager
Attributes
- #[Inject]
$authStorageManager
public
AuthStorageManager
$authStorageManager
Attributes
- #[Inject]
$box
Mailbox: `received` / `sent`; empty means both.
public
string
$box
= ''
Attributes
- #[Persistent]
$container
public
Container
$container
Attributes
- #[Inject]
$currencyContext
public
CurrencyContext
$currencyContext
Attributes
- #[Inject]
$currencyManager
public
CurrencyManager
$currencyManager
Attributes
- #[Inject]
$deviceDetector
public
DeviceDetector
$deviceDetector
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]
$eventDispatcher
public
EventDispatcher
$eventDispatcher
Attributes
- #[Inject]
$googleIntegrations
Google services from the third-party connections, used in the page head (`analytics.latte` templates).
public
GoogleIntegrations
$googleIntegrations
Attributes
- #[Inject]
$identityAssetManager
public
AssetManager
$identityAssetManager
Attributes
- #[Inject]
$jwtManager
public
JwtManager
$jwtManager
Attributes
- #[Inject]
$languageContext
public
LanguageContext
$languageContext
Attributes
- #[Inject]
$languageManager
public
LanguageManager
$languageManager
Attributes
- #[Inject]
$localizationContext
public
LocalizationContext
$localizationContext
Attributes
- #[Inject]
$localizationManager
public
LocalizationManager
$localizationManager
Attributes
- #[Inject]
$loginDeviceCookie
"Known device" cookie for the password login throttle ({@see self::rememberLoginDevice()}).
public
LoginDeviceCookie
$loginDeviceCookie
Attributes
- #[Inject]
$modalWindowsFactory
public
ModalWindowsFactory
$modalWindowsFactory
Attributes
- #[Inject]
$pageManager
public
PageManager
$pageManager
Attributes
- #[Inject]
$presenterContext
public
PresenterContext
$presenterContext
Attributes
- #[Inject]
$reCaptchaRuntime
Decides at runtime whether forms use reCAPTCHA (configuration plus the connection set up in the admin).
public
ReCaptchaRuntime
$reCaptchaRuntime
Attributes
- #[Inject]
$routerDispatcher
public
RouterDispatcher
$routerDispatcher
Tags
$securityConfig
reCAPTCHA switch for templates (`$reCaptchaEnabled` in the `scripts.latte` templates).
public
SecurityConfig
$securityConfig
Attributes
- #[Inject]
$settingContext
public
SettingContext
$settingContext
Attributes
- #[Inject]
$settingManager
public
SettingManager
$settingManager
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]
$themeContext
public
ThemeContext
$themeContext
Attributes
- #[Inject]
$themeManager
public
ThemeManager
$themeManager
Attributes
- #[Inject]
$themeResolver
public
DefaultThemeResolver
$themeResolver
Attributes
- #[Inject]
$translator
public
ITranslator
$translator
Tags
$translatorSessionResolver
public
Session
$translatorSessionResolver
Tags
$unread
Show only conversations with an unread message.
public
bool
$unread
= false
Attributes
- #[Persistent]
$userManager
public
UserManager
$userManager
Attributes
- #[Inject]
$debugMode
protected
bool
$debugMode
= false
$metaData
protected
MetaDataDTO|null
$metaData
= null
$ogData
protected
OgDataDTO|null
$ogData
= null
$pageEntity
protected
Page|null
$pageEntity
= null
$productionMode
protected
bool
$productionMode
= false
$siteIdentity
protected
SiteIdentityDto|null
$siteIdentity
= null
$translatorDomain
protected
string
$translatorDomain
= 'front.base.presenters.message'
$isLoggingIn
private
bool
$isLoggingIn
= false
$messageManager read-only
private
MessageManager
$messageManager
$messageParticipantManager read-only
private
MessageParticipantManager
$messageParticipantManager
$messageThreadManager read-only
private
MessageThreadManager
$messageThreadManager
$newMessageIds
private
array<int, true>
$newMessageIds
= []
ids of messages that were unread for me when the thread was opened
$openedThread
private
MessageThread|null
$openedThread
= null
$participantViews
private
array<int, MessageParticipantView>
$participantViews
= []
$readMessageIds
private
array<int, true>
$readMessageIds
= []
ids of MY messages the other party read (only with "message read receipts" enabled)
$systemEvents
private
array<int, array{event: string, name: string}>
$systemEvents
= []
system messages (joined / left) by message id
$theme
private
Theme|null
$theme
= null
$threadMessages
private
array<int, Message>
$threadMessages
= []
Methods
__construct()
public
__construct(MessageThreadManager $messageThreadManager, MessageParticipantManager $messageParticipantManager, MessageManager $messageManager) : mixed
Parameters
- $messageThreadManager : MessageThreadManager
- $messageParticipantManager : MessageParticipantManager
- $messageManager : MessageManager
actionDetail()
public
actionDetail(int $id) : void
Parameters
- $id : int
actionList()
public
actionList() : void
beforeRender()
public
beforeRender() : void
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>
-
datafrom the ApiloginExternal(token, refreshToken, payload)
Return values
boolcreateComponent()
public
createComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullformatLayoutTemplateFiles()
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
ContainergetDefaultUrlParams()
public
getDefaultUrlParams() : array<string, null>
Return values
array<string, null>getPageEntity()
public
getPageEntity() : Page|null
Return values
Page|nullgetRouterDispatcher()
public
getRouterDispatcher() : RouterDispatcher
Return values
RouterDispatchergetTranslator()
public
getTranslator() : ITranslator
Return values
ITranslatorhandleChangeLocale()
public
handleChangeLocale(string $locale) : void
Parameters
- $locale : string
handleHide()
"Delete for me": the thread stays for the other party.
public
handleHide(int $threadId) : void
Parameters
- $threadId : int
handleLogout()
public
handleLogout() : void
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
handleSwitchBox()
Switches the mailbox without reloading the whole page.
public
handleSwitchBox([string $box = '' ]) : void
Parameters
- $box : string = ''
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
Return values
boolinitializeTranslator()
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
onReplySuccess()
public
onReplySuccess(Form $form, ArrayHash<string|int, mixed> $values) : void
Parameters
- $form : Form
- $values : ArrayHash<string|int, mixed>
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
renderDetail()
public
renderDetail(int $id) : void
Parameters
- $id : int
renderList()
public
renderList([int $page = 1 ][, int $count = 20 ]) : void
Parameters
- $page : int = 1
- $count : int = 20
setConfigParameters()
public
setConfigParameters([bool $debugMode = false ][, bool $productionMode = false ]) : void
Parameters
- $debugMode : bool = false
- $productionMode : bool = false
setTranslator()
public
setTranslator(ITranslator $translator) : $this
Parameters
- $translator : ITranslator
Return values
$thisstartup()
public
startup() : void
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
TbuildSiteIdentity()
protected
buildSiteIdentity() : SiteIdentityDto
Return values
SiteIdentityDtocheckAuthentication()
protected
checkAuthentication() : void
createComponentFrontSystemModalWindows()
protected
createComponentFrontSystemModalWindows() : ModalWindows
Return values
ModalWindowscreateComponentReplyForm()
protected
createComponentReplyForm() : Form
Return values
FormcurrentAbsoluteUrl()
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
stringfallbackToMainLocalization()
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
boolgetSessionKey()
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
stringgetSessionSection()
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
Return values
SessionSectioninitializeMetaData()
protected
initializeMetaData() : void
initializeOgData()
protected
initializeOgData() : void
initializePresenterContext()
protected
initializePresenterContext() : void
initSiteIdentity()
protected
initSiteIdentity() : void
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
boolloadPageEntity()
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|nulllogout()
protected
logout() : void
metaData()
Returns the page meta data; filled by startup, an empty DTO before that.
protected
metaData() : MetaDataDTO
Return values
MetaDataDTOogData()
Returns the page OG data; filled by `initializeOgData()` in startup, an empty DTO before that.
protected
ogData() : OgDataDTO
Return values
OgDataDTOprepareMetaData()
protected
prepareMetaData() : MetaDataDTO
Return values
MetaDataDTOprepareOgData()
protected
prepareOgData() : OgDataDTO
Return values
OgDataDTOresolveBox()
Mailbox from the persistent parameter; `null` means both (received and sent).
protected
resolveBox() : MessageBox|null
Return values
MessageBox|nullsetTranslatorDomain()
protected
setTranslatorDomain() : void
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|nullbuildSystemEvents()
Builds the system messages "X joined / left the conversation". The message text in the DB is a code (see {@see MessageSystemEvent}); the sentence is composed here from the translation and the participant's current name (also a former one, the Api still returns the row).
private
buildSystemEvents(array<int, Message> $messages, array<int, MessageParticipantView> $participantMap) : array<int, array{event: string, name: string}>
Parameters
- $messages : array<int, Message>
- $participantMap : array<int, MessageParticipantView>
Return values
array<int, array{event: string, name: string}>collectGuestContacts()
Returns contacts of participants without an account: the only way to reply to an `email_only` thread.
private
collectGuestContacts(array<int, MessageParticipantView> $participants) : array<int, MessageParticipantView>
Parameters
- $participants : array<int, MessageParticipantView>
Return values
array<int, MessageParticipantView>createIdentity()
private
createIdentity(array<string, mixed> $payload, string $token) : SimpleIdentity|null
Parameters
- $payload : array<string, mixed>
- $token : string
Return values
SimpleIdentity|nullcreateMultiplierComponent()
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|nullexpireIdleLogin()
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
boolfindMyParticipantRow()
My participant row (`myList`, the caller's only); carries `last_read_datetime` and the counter.
private
findMyParticipantRow(int $id) : MessageParticipant|null
Parameters
- $id : int
Return values
MessageParticipant|nullformatLayoutCandidates()
private
formatLayoutCandidates(Theme $theme, string $layout) : array<int, string>
Parameters
- $theme : Theme
- $layout : string
Return values
array<int, string>getClientIp()
private
getClientIp() : string
Return values
stringgetCurrentUserId()
private
getCurrentUserId() : int|null
Return values
int|nullidentitySetting()
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
stringidentitySettingOrNull()
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|nullindexById()
private
indexById(array<int, MessageParticipantView> $participants) : array<int, MessageParticipantView>
Parameters
- $participants : array<int, MessageParticipantView>
Return values
array<int, MessageParticipantView>initConversation()
Loads messages and participants (other party's name, guest contact) and counts new messages.
private
initConversation(int $id) : void
Participants do not come from MessageParticipant:myList (the caller's rows only, so the
other party's messages would have no author) but from myThreadParticipants: name plus,
for a guest, the contact, nothing more.
Parameters
- $id : int
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
initializePage()
private
initializePage() : void
isDevelopment()
private
isDevelopment() : bool
Return values
boollayoutFileExists()
private
layoutFileExists(array<int, string> $files) : bool
Parameters
- $files : array<int, string>
Return values
boolloadIdentityAssets()
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|nullloadMyParticipantsByThread()
Returns my participant rows by thread; they carry unread, role and archive.
private
loadMyParticipantsByThread() : array<int, MessageParticipant>
It is :Api:Base:MessageParticipant:myList, the standard OwnedListTrait: the server sets
the scope, the filter from here can only narrow it.
Return values
array<int, MessageParticipant>loadThread()
private
loadThread(int $id) : MessageThread|null
Parameters
- $id : int
Return values
MessageThread|nulllocalizationCurrencyKey()
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|nulllocalizedIdentitySetting()
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
stringlogoutNetteUser()
private
logoutNetteUser() : void
processFailedLogin()
private
processFailedLogin(AuthSessionStorage $authStorage, Result $result, string $username) : void
Parameters
- $authStorage : AuthSessionStorage
- $result : Result
- $username : string
processInvalidToken()
private
processInvalidToken(AuthStorageInterface $authStorage) : void
Parameters
- $authStorage : AuthStorageInterface
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
processMissingToken()
private
processMissingToken() : void
processSuccessfulLogin()
private
processSuccessfulLogin(AuthSessionStorage $authStorage, Result $result, string $username[, bool $remember = false ]) : void
Parameters
- $authStorage : AuthSessionStorage
- $result : Result
- $username : string
- $remember : bool = false
processValidToken()
private
processValidToken(AuthSessionStorage $authStorage, string $token) : void
Parameters
- $authStorage : AuthSessionStorage
- $token : string
readLoginDeviceToken()
Returns the raw known-device cookie for the Api login (the Api verifies its signature).
private
readLoginDeviceToken() : string|null
Return values
string|nullredirectAfterLoginAction()
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
requireLoggedUser()
private
requireLoggedUser() : int
Return values
intresolveLoginErrorMessage()
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
stringrevokeTokensOnLogout()
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
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