CoolCMS API

ArticlePresenter extends BasePresenter
in package
uses ArticleInitTrait, ArticleListTrait, ArticleDetailTrait, PermissionTrait, CategoryTrait, RegionTrait

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.
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 = ['translations', 'asset.translations', 'categor...
Includes of the list, the same for the plain DB path and the search endpoint.
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
$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
$localizationContext  : LocalizationContext
$localizationManager  : LocalizationManager
$loginDeviceCookie  : LoginDeviceCookie
"Known device" cookie for the password login throttle ({@see self::rememberLoginDevice()}).
$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).
$regionSlugTranslator  : RegionNameTranslator
Router translator, the same one that builds the slug from the id in links (see init below).
$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
$article  : Article|null
$articleManager  : ArticleManager
$categoryManager  : CategoryManager
$currentCategory  : Category|null
$currentRegion  : Region|null
$esSearcher  : EsSearcher
$hasPaidAccess  : bool
$isLoggingIn  : bool
$ratingFactory  : RatingFactory
$regionManager  : RegionManager
$theme  : Theme|null
$userPaymentManager  : UserPaymentManager

Methods

__construct()  : mixed
actionDetail()  : void
actionList()  : void
beforeRender()  : void
checkAccessPermission()  : bool
completeExternalLogin()  : bool
Completes an OAuth login (`LoginExternalComponent`) with the same storage as a password login.
createComponent()  : IComponent|null
createComponentFrontBlogArticleRating()  : Rating
formatLayoutTemplateFiles()  : array<string|int, mixed>
Returns candidate layout files; Nette takes the first existing one.
getArticle()  : Article|null
getContainer()  : Container
getCurrentCategory()  : Category|null
getCurrentRegion()  : Region|null
getDefaultUrlParams()  : array<string, null>
getPageEntity()  : Page|null
getRouterDispatcher()  : RouterDispatcher
getTranslator()  : ITranslator
handleChangeLocale()  : 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
initCurrentRegion()  : void
initializeTranslator()  : void
loadModalWindowComponent()  : void
loginWithCredentials()  : void
Logs in by username and password; called only by the login form (after validation and CSRF).
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
renderPermissionDenied()  : void
setConfigParameters()  : void
setTranslator()  : $this
startup()  : void
typedComponent()  : T
Returns a subcomponent with a verified type.
buildSiteIdentity()  : SiteIdentityDto
checkAuthentication()  : void
createComponentFrontSystemModalWindows()  : ModalWindows
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
setTranslatorDomain()  : void
buildDefaultOgImage()  : OgImageDTO|null
Builds the default OG image from the site identity (admin, settings, site identity).
checkUserPaymentValidity()  : bool
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
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
isRegionBranchActive()  : bool
Whether the region and all its ancestors are active (nested set: an ancestor encloses lft/rgt).
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>
Filters of the plain DB path: visibility plus full-text. The search endpoint uses only the visibility part; full-text is handled on the Api side (ES, fallback `MATCH_AGAINST`).
prepareOrderBy()  : array<string, bool>
prepareRegionFilter()  : void
prepareSearchFilter()  : Filter
Full-text of the plain DB path (fallback): ES ids go to `SearchIdFilter` (visibility, pagination and totalCount stay in the DB phase 1); with ES off or down (circuit breaker) a transparent fallback to MySQL `MATCH_AGAINST`, behaving as before.
prepareView()  : void
prepareVisibilityFilters()  : array<int, Filter>
Eligibility of an article in the list (activation, publication, category, paid access).
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).
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()  : Article>, 1: int, 2: bool, 3: array>}|null
Searches through the Api endpoint `api/blog/article/search` instead of building the filter in the presenter. Three states:
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.

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.

private mixed LIST_INCLUDES = ['translations', 'asset.translations', 'categories.translations', 'tags.translations', 'region.translations', 'user']

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]

$regionSlugTranslator

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

public RegionNameTranslator $regionSlugTranslator
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]

Methods

actionDetail()

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

actionList()

public actionList(int|null $page, string|int|null $category, string|int|null $loc, int|null $order) : void
Parameters
$page : int|null
$category : string|int|null
$loc : string|int|null
$order : int|null

checkAccessPermission()

public checkAccessPermission(array<string|int, mixed> $categoryList) : bool
Parameters
$categoryList : array<string|int, mixed>
Return values
bool

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>

handleChangeLocale()

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

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

initCurrentRegion()

public initCurrentRegion() : void

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

renderDetail()

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

renderList()

public renderList(int $page, string|int|null $category, string|int $loc, int $order[, int $count = 20 ]) : void
Parameters
$page : int
$category : string|int|null
$loc : string|int
$order : int
$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
$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

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

checkUserPaymentValidity()

private checkUserPaymentValidity() : bool
Return values
bool

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>

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

isRegionBranchActive()

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

private isRegionBranchActive(Region $region) : bool
Parameters
$region : Region
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()

Filters of the plain DB path: visibility plus full-text. The search endpoint uses only the visibility part; full-text is handled on the Api side (ES, fallback `MATCH_AGAINST`).

private prepareFilters() : array<int, Filter>
Return values
array<int, Filter>

prepareOrderBy()

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

prepareRegionFilter()

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

prepareSearchFilter()

Full-text of the plain DB path (fallback): ES ids go to `SearchIdFilter` (visibility, pagination and totalCount stay in the DB phase 1); with ES off or down (circuit breaker) a transparent fallback to MySQL `MATCH_AGAINST`, behaving as before.

private prepareSearchFilter(string $search) : Filter
Parameters
$search : string
Return values
Filter

prepareVisibilityFilters()

Eligibility of an article in the list (activation, publication, category, paid access).

private prepareVisibilityFilters() : array<int, Filter>

Also sent to the search endpoint: visibility is always held by the DB, ES ids are only candidates.

Return values
array<int, Filter>

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

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/blog/article/search` instead of building the filter in the presenter. Three states:

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

(a) search without a manual order choice: orderBys = null, ES orders and paginates by score (fromEs: true); visibility is still held by the DB (filters below), (b) search with a manual choice (/o-N in the URL): orderBys from prepareOrderBy(), the DB orders, paginates and counts over the ES id set and relevance is not used, (c) without a search the caller never gets here and nothing changes.

Highlighted snippets come only in state (a); they are fragments from ES.

null means use the plain DB path: the endpoint gave no list (deny or bridge outage), or ES is down and without a manual choice the DB branch of the endpoint would return an unordered list; falling back to published descending is a deliberate behavior change during an outage.

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

[entities, totalCount, fromEs, highlights]

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