CategoryTrait
Resolves the current category from the route parameter `category`.
The parameter is translated to an id by ProductCategoryNameTranslator (see
ProductListRouteFactory), like Blog CategoryTrait. Falls back to a direct lookup through
translations.href when the translator returns the raw string (route without route_factory,
cache miss).
Table of Contents
Properties
- $categorySlugTranslator : ProductCategoryNameTranslator
- Router translator; the same one that builds the slug from the id in links (see init below).
- $currentCategory : ProductCategory|null
Methods
- getCurrentCategory() : ProductCategory|null
- initCurrentCategory() : void
- isCategoryBranchActive() : bool
- Whether the category and all its ancestors are active (nested set: an ancestor encloses lft/rgt).
Properties
$categorySlugTranslator
Router translator; the same one that builds the slug from the id in links (see init below).
public
ProductCategoryNameTranslator
$categorySlugTranslator
Attributes
- #[Inject]
$currentCategory
private
ProductCategory|null
$currentCategory
= null
Methods
getCurrentCategory()
public
getCurrentCategory() : ProductCategory|null
Return values
ProductCategory|nullinitCurrentCategory()
public
initCurrentCategory() : 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