PHP Class Elcodi\Store\ProductBundle\Services\StoreCategoryTree

Inheritance: extends Elcodi\Component\Core\Wrapper\Abstracts\AbstractCacheWrapper
Show file Open project: elcodi/bamboo Class Usage Examples

Protected Properties

Property Type Description
$locale Elcodi\Component\Language\Entity\Interfaces\LocaleInterface Locale in which the categories are stored

Public Methods

Method Description
__construct ( Elcodi\Component\Product\Services\CategoryTree $categoryTreeService, boolean $loadOnlyCategoriesWithProducts, string $key, Elcodi\Component\Language\Entity\Interfaces\LocaleInterface $locale ) Construct method
getStoreCategoryTree ( ) : array Get category tree
load ( ) : array Load Category tree from cache.
reload ( ) : array Reload Category tree from cache

Protected Methods

Method Description
buildCategoryTreeAndSaveIntoCache ( ) : array Build category tree and save it into cache
buildStoreCategoryTree ( ) : Array Build the store category tree (Can change depending on categories enabled and store config).
formatCategoryNode ( array $categoryNode ) : array Formats a category node form a category tree to return it on a store friendly format.
formatCategoryTree ( array &$categoryTree ) : array Formats a category tree to return it on a store friendly format.
getKey ( ) Get current key
isCategoryEnabled ( Elcodi\Component\Product\Entity\Category $category ) : boolean Checks if a category is enabled. A category can be disabled by itself or by other store configurations like the options to only load categories with products.
loadCategoryTreeFromCache ( ) : array Load category tree from cache
saveCategoryTreeIntoCache ( array $categoryTree ) Save given category tree into cache

Method Details

__construct() public method

Construct method
public __construct ( Elcodi\Component\Product\Services\CategoryTree $categoryTreeService, boolean $loadOnlyCategoriesWithProducts, string $key, Elcodi\Component\Language\Entity\Interfaces\LocaleInterface $locale )
$categoryTreeService Elcodi\Component\Product\Services\CategoryTree The category tree service
$loadOnlyCategoriesWithProducts boolean Load only categories with products
$key string Key where to store info
$locale Elcodi\Component\Language\Entity\Interfaces\LocaleInterface Locale of the categories

buildCategoryTreeAndSaveIntoCache() protected method

Build category tree and save it into cache
protected buildCategoryTreeAndSaveIntoCache ( ) : array
return array Category tree

buildStoreCategoryTree() protected method

Build the store category tree (Can change depending on categories enabled and store config).
protected buildStoreCategoryTree ( ) : Array
return Array Category tree

formatCategoryNode() protected method

A node is supposed to have an entity and a children key.
protected formatCategoryNode ( array $categoryNode ) : array
$categoryNode array The category node to format
return array The formatted category node.

formatCategoryTree() protected method

Formats a category tree to return it on a store friendly format.
protected formatCategoryTree ( array &$categoryTree ) : array
$categoryTree array The categories tree.
return array The formatted category tree

getKey() protected method

Get current key
protected getKey ( )

getStoreCategoryTree() public method

Get category tree
public getStoreCategoryTree ( ) : array
return array Category tree

isCategoryEnabled() protected method

Checks if a category is enabled. A category can be disabled by itself or by other store configurations like the options to only load categories with products.
protected isCategoryEnabled ( Elcodi\Component\Product\Entity\Category $category ) : boolean
$category Elcodi\Component\Product\Entity\Category The category to check.
return boolean If the category is enabled and should be showed on the categories tree.

load() public method

If element is not loaded yet, loads it from Database and store it into cache.
public load ( ) : array
return array Category tree loaded

loadCategoryTreeFromCache() protected method

Load category tree from cache
protected loadCategoryTreeFromCache ( ) : array
return array Category tree

reload() public method

Empty cache and load again
public reload ( ) : array
return array Category tree loaded

saveCategoryTreeIntoCache() protected method

Save given category tree into cache
protected saveCategoryTreeIntoCache ( array $categoryTree )
$categoryTree array Category tree

Property Details

$locale protected property

Locale in which the categories are stored
protected LocaleInterface,Elcodi\Component\Language\Entity\Interfaces $locale
return Elcodi\Component\Language\Entity\Interfaces\LocaleInterface