ProductSetPresenter
extends BasePresenter
in package
uses
AddToCartTrait, CategoryTrait, ProductSetListTrait, ProductSetDetailTrait
Product catalog presenter (`Front:Eshop:ProductSet`).
Like Blog ArticlePresenter / Bazaar AdvertPresenter: thin presenter, all logic in the
traits (Inits, Lists, Details).
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'
- DETAIL_INCLUDES : mixed = [ 'translations', 'product.translations', 'prod...
- 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', 'productState', 'tags.translat...
- `ratingThread`: the rating on the product card. The thread carries denormalized aggregates (`ratingCount`, `ratingAvg`), so it is one extra join, not a product query; without the include the card would touch a lazy association and the list would get N+1.
- 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.
- SETTINGS_MODULE : mixed = 4
- Settings module (`cms_system_settings`): e-shop = 4.
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 : ProductCategoryNameTranslator
- Router translator; the same one that builds the slug from the id in links (see init below).
- $checkoutManager : CheckoutManager
- Customer orders; the detail reads only one thing from them: who bought this set ("verified purchase" on reviews and the right to write a review).
- $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
- $socialsShareFactory : SocialsShareFactory
- Detail sharing to social networks; the same component as the advert detail.
- $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
- $cart : CartManager
- $currentCategory : ProductCategory|null
- $esSearcher : EsSearcher
- $isLoggingIn : bool
- $parameterManager : ParameterManager
- $productCategoryManager : ProductCategoryManager
- $productSet : ProductSet|null
- $productSetManager : ProductSetManager
- $ratingFactory : RatingFactory
- $theme : Theme|null
- $variants : array<int, ProductSet>
- Variants = other sets of the same product (`product_id`), including the displayed one.
- $visibleAccessories : array<int, object>
- $visibleSetItems : array<int, object>
Methods
- __construct() : mixed
- actionDetail() : void
- actionList() : void
- beforeRender() : void
- Tells templates whether the e-shop is in "catalog only" mode (`4/catalog.only`); cart CTAs are not rendered at all then.
- completeExternalLogin() : bool
- Completes an OAuth login (`LoginExternalComponent`) with the same storage as a password login.
- createComponent() : IComponent|null
- createComponentRating() : Rating
- createComponentSocialsShare() : SocialsShare
- formatLayoutTemplateFiles() : array<string|int, mixed>
- Returns candidate layout files; Nette takes the first existing one.
- getContainer() : Container
- getCurrentCategory() : ProductCategory|null
- getDefaultUrlParams() : array<string, null>
- getPageEntity() : Page|null
- getProductSet() : ProductSet|null
- Returns the loaded detail set; read by the breadcrumb component ({@see \App\UI\Front\Eshop\Components\BreadcrumbComponent\Breadcrumb}), like `getCurrentCategory()` on the list. It is `null` before `actionDetail()`.
- getRouterDispatcher() : RouterDispatcher
- getTranslator() : ITranslator
- handleAddToCart() : void
- 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
- 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
- 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).
- 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
- isSetOrderable() : bool
- Returns whether the set may be ordered.
- 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.
- loadVariants() : array<int, ProductSet>
- Returns the other sets of the same product = variants switchable in the buy box.
- 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
- prepareFilters() : array<int, Filter>
- prepareOrderBy() : array<string, bool>
- prepareSearchFilter() : Filter
- Applies the fulltext through Elasticsearch (id -> `SearchIdFilter`); visibility, pagination and publish window stay in DB phase 1 (`ProductSetEligibilityFilters` are always applied). With ES off, an outage (circuit breaker) or a short query it falls back transparently to MySQL `MATCH_AGAINST`, with identical behavior to the original. Same as Blog `ArticleListTrait` / Bazaar `ParameterTrait`.
- prepareSearchFilters() : array<int, Filter>
- Builds the filters for the search endpoint = everything except fulltext (handled on the Api side): `ProductSetEligibilityFilters`, category and parameter filters.
- 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).
- resolveFeeCurrentPrices() : array<int, string>
- Returns the currently valid price of each fee of the set, for display.
- 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()
: ProductSet>, 1: int, 2: bool, 3: array
>} |null - Searches through the Api endpoint `api/eshop/product-set/search`. Three states (only the search path is handled for the e-shop; facets stay unchanged):
- 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'
DETAIL_INCLUDES
private
mixed
DETAIL_INCLUDES
= [
'translations',
'product.translations',
'product.categories.translations',
'productState',
'asset',
'assetRels.asset.translations',
'setItems.childSet.translations',
'accessories.accessorySet.translations',
'accessories.accessorySet.asset',
// The accessory card is the same as in the list (`Items/_item.latte`) and renders tags and
// state; without these includes they would be lazy-loaded per card (N+1).
'accessories.accessorySet.productState.translations',
'accessories.accessorySet.tags.translations',
'tags.translations',
'fees.translations',
// The fee is priced with the same rate as the set ({@see resolveFeeCurrentPrices()}), so
// the `fees.prices.vat` include is not needed.
'fees.prices',
'fees.feeType.translations',
'links.translations',
'links.linkType.translations',
'parameterRels.parameter.translations',
// Options = child parameters. `AbstractParameterHandler::resolveOptionLabel()` looks up
// the chosen option by the stored id there; without this include the collection is empty,
// the resolve returns null and the parameter table shows the bare id instead of the label.
'parameterRels.parameter.optionsCollection.translations',
'commentThread',
'ratingThread',
]
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
`ratingThread`: the rating on the product card. The thread carries denormalized aggregates (`ratingCount`, `ratingAvg`), so it is one extra join, not a product query; without the include the card would touch a lazy association and the list would get N+1.
private
mixed
LIST_INCLUDES
= ['translations', 'productState', 'tags.translations', 'asset', '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.
SETTINGS_MODULE
Settings module (`cms_system_settings`): e-shop = 4.
private
mixed
SETTINGS_MODULE
= 4
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]
$categorySlugTranslator
Router translator; the same one that builds the slug from the id in links (see init below).
public
ProductCategoryNameTranslator
$categorySlugTranslator
Attributes
- #[Inject]
$checkoutManager
Customer orders; the detail reads only one thing from them: who bought this set ("verified purchase" on reviews and the right to write a review).
public
CheckoutManager
$checkoutManager
Attributes
- #[Inject]
$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]
$socialsShareFactory
Detail sharing to social networks; the same component as the advert detail.
public
SocialsShareFactory
$socialsShareFactory
Attributes
- #[Inject]
$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
$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
= ''
$cart read-only
private
CartManager
$cart
$currentCategory
private
ProductCategory|null
$currentCategory
= null
$esSearcher read-only
private
EsSearcher
$esSearcher
$isLoggingIn
private
bool
$isLoggingIn
= false
$parameterManager read-only
private
ParameterManager
$parameterManager
$productCategoryManager read-only
private
ProductCategoryManager
$productCategoryManager
$productSet
private
ProductSet|null
$productSet
= null
$productSetManager read-only
private
ProductSetManager
$productSetManager
$ratingFactory read-only
private
RatingFactory
$ratingFactory
$theme
private
Theme|null
$theme
= null
$variants
Variants = other sets of the same product (`product_id`), including the displayed one.
private
array<int, ProductSet>
$variants
= []
Empty array when the product has no other set (the switcher is then not rendered).
$visibleAccessories
private
array<int, object>
$visibleAccessories
= []
accessories that pass eligibility (see actionDetail())
$visibleSetItems
private
array<int, object>
$visibleSetItems
= []
bundle items that pass eligibility (see actionDetail())
Methods
__construct()
public
__construct(ProductSetManager $productSetManager, ProductCategoryManager $productCategoryManager, ParameterManager $parameterManager, RatingFactory $ratingFactory, CartManager $cart, EsSearcher $esSearcher) : mixed
Parameters
- $productSetManager : ProductSetManager
- $productCategoryManager : ProductCategoryManager
- $parameterManager : ParameterManager
- $ratingFactory : RatingFactory
- $cart : CartManager
- $esSearcher : EsSearcher
actionDetail()
public
actionDetail(int|string|null $slug, int|string|null $name, int $id) : void
Parameters
- $slug : int|string|null
- $name : int|string|null
- $id : int
actionList()
public
actionList([int $page = 1 ][, string|int|null $category = null ][, string|null $search = null ][, int $order = 0 ]) : void
Parameters
- $page : int = 1
- $category : string|int|null = null
- $search : string|null = null
- $order : int = 0
beforeRender()
Tells templates whether the e-shop is in "catalog only" mode (`4/catalog.only`); cart CTAs are not rendered at all then.
public
beforeRender() : void
$allowOutOfStockOrder (4/order.outOfStock.allowed) decides whether "Add to cart" is
offered even for sold-out goods; the rule itself is held by
ProductSet::isOrderable(), the template only
passes the switch value.
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|nullcreateComponentRating()
public
createComponentRating() : Rating
Return values
RatingcreateComponentSocialsShare()
public
createComponentSocialsShare() : SocialsShare
Return values
SocialsShareformatLayoutTemplateFiles()
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
ContainergetCurrentCategory()
public
getCurrentCategory() : ProductCategory|null
Return values
ProductCategory|nullgetDefaultUrlParams()
public
getDefaultUrlParams() : array<string, null>
Return values
array<string, null>getPageEntity()
public
getPageEntity() : Page|null
Return values
Page|nullgetProductSet()
Returns the loaded detail set; read by the breadcrumb component ({@see \App\UI\Front\Eshop\Components\BreadcrumbComponent\Breadcrumb}), like `getCurrentCategory()` on the list. It is `null` before `actionDetail()`.
public
getProductSet() : ProductSet|null
Return values
ProductSet|nullgetRouterDispatcher()
public
getRouterDispatcher() : RouterDispatcher
Return values
RouterDispatchergetTranslator()
public
getTranslator() : ITranslator
Return values
ITranslatorhandleAddToCart()
public
handleAddToCart(int $setId[, int $quantity = 1 ]) : void
Parameters
- $setId : int
- $quantity : int = 1
handleChangeLocale()
public
handleChangeLocale(string $locale) : void
Parameters
- $locale : string
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
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
boolinitCurrentCategory()
public
initCurrentCategory() : 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(int|string|null $slug, int|string|null $name, int $id) : void
Parameters
- $slug : int|string|null
- $name : int|string|null
- $id : int
renderList()
public
renderList([int $page = 1 ][, string|int|null $category = null ][, string|null $search = null ][, int $order = 0 ]) : void
Parameters
- $page : int = 1
- $category : string|int|null = null
- $search : string|null = null
- $order : int = 0
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
ModalWindowscurrentAbsoluteUrl()
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
OgDataDTOsetTranslatorDomain()
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|nullcreateIdentity()
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
boolformatLayoutCandidates()
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
stringidentitySetting()
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|nullinitializeDisplayRegion()
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
isCategoryBranchActive()
Whether the category and all its ancestors are active (nested set: an ancestor encloses lft/rgt).
private
isCategoryBranchActive(ProductCategory $category) : bool
Parameters
- $category : ProductCategory
Return values
boolisDevelopment()
private
isDevelopment() : bool
Return values
boolisSetOrderable()
Returns whether the set may be ordered.
private
isSetOrderable(int $setId) : bool
Availability is read from the same source as the list
(ProductSetManager::fetchAvailability()), so
the gate cannot diverge from what the customer saw in the catalog. A set unknown to
availability (deleted, nonexistent) behaves as availableSets = null, i.e. unorderable.
Parameters
- $setId : int
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|nullloadVariants()
Returns the other sets of the same product = variants switchable in the buy box.
private
loadVariants(ProductSet $set) : array<int, ProductSet>
The filters are the same as for the list (ProductSetEligibilityFilters::build());
without them the switcher would offer a deleted or unpublished set that gives 404 on the
detail (same reason as for the set composition and accessories in renderDetail()).
A bundle (typeId = 2) has no variants: it groups different products, not sizes of one.
A set with a NULL product FK (migrated cards) has none either: without a product there
is nothing to look siblings up by.
Parameters
- $set : ProductSet
Return values
array<int, ProductSet>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|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
prepareFilters()
private
prepareFilters() : array<int, Filter>
Return values
array<int, Filter>prepareOrderBy()
private
prepareOrderBy() : array<string, bool>
Return values
array<string, bool>prepareSearchFilter()
Applies the fulltext through Elasticsearch (id -> `SearchIdFilter`); visibility, pagination and publish window stay in DB phase 1 (`ProductSetEligibilityFilters` are always applied). With ES off, an outage (circuit breaker) or a short query it falls back transparently to MySQL `MATCH_AGAINST`, with identical behavior to the original. Same as Blog `ArticleListTrait` / Bazaar `ParameterTrait`.
private
prepareSearchFilter(string $search) : Filter
Parameters
- $search : string
Return values
FilterprepareSearchFilters()
Builds the filters for the search endpoint = everything except fulltext (handled on the Api side): `ProductSetEligibilityFilters`, category and parameter filters.
private
prepareSearchFilters() : array<int, Filter>
Return values
array<int, Filter>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
resolveFeeCurrentPrices()
Returns the currently valid price of each fee of the set, for display.
private
resolveFeeCurrentPrices(ProductSet $set) : array<int, string>
The series is append-only and resolved per fee (unlike the ProductSet price there is no
batch resolver; a set has only a handful of fees, so no N+1 risk). The fee is
informative: the rate is the same as for the set ($set->getCurrentPriceVatPercents()),
not from the fee's own price row (fee_prices.cms_system_vats_vat_id / Vat entity).
VAT is added only when the set charges it ($set->isCurrentPriceChargeVat()); both the
rate and chargeVat are filled earlier in actionDetail()
(BatchDecorationTrait::decorateWithPriceAndAvailability()).
Parameters
- $set : ProductSet
Return values
array<int, string> —feeId => display price (numeric string)
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
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
searchViaApi()
Searches through the Api endpoint `api/eshop/product-set/search`. Three states (only the search path is handled for the e-shop; facets stay unchanged):
private
searchViaApi(string $search, bool $orderChosen, Paginator|null $paginator) : ProductSet>, 1: int, 2: bool, 3: array>} |null
(a) search without a manual sort choice: orderBys = null, ES sorts and paginates by
score (fromEs: true); eligibility is still held by the DB,
(b) search with a manual choice (o-N): orderBys from prepareOrderBy(), the DB
sorts, paginates and counts over the ES id set, so the price still sorts exactly,
(c) without search this path is not taken at all and nothing changes.
Sorting by price (o-2 / o-3) is essential for the e-shop and stays fully working; it
is state (b), where relevance yields to DB sorting.
null means use the plain DB path (DENY, bridge outage or ES unavailable).
Parameters
- $search : string
- $orderChosen : bool
- $paginator : Paginator|null
Return values
ProductSet>, 1: int, 2: bool, 3: arraysetNetteUser()
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