CategoryRepositoryReader
in package
implements
CategoryRepositoryReaderInterface
Class CategoryRepositoryReader
This class provides methods for fetching specific category records from the database and is used in the category repository among the classes for writing and deleting category records.
Tags
Interfaces, Classes and Traits
- CategoryRepositoryReaderInterface
- Interface CategoryRepositoryReaderInterface
Table of Contents
- $categoryFactory : CategoryFactoryInterface
- Category factory.
- $db : CI_DB_query_builder
- Database connector.
- __construct() : mixed
- CategoryRepositoryReader constructor.
- getActiveCategoryIdsTree() : IdCollection
- Returns an id collection with the ids of the active subcategories.
- getById() : StoredCategoryInterface
- Returns a category.
- getByParentId() : IdCollection
- Returns all Categories with the provided parent ID.
- getCategoryIdsTree() : IdCollection
- Returns an id collection with the ids of subcategories.
- _createCategoryByArray() : StoredCategory
- Creates a category instance.
- _getActiveCategoryIdsTreeArray() : array<string|int, mixed>
- Fetches the ids of the active subcategories from the passed parent category.
- _getCategoryIdsTreeArray() : array<string|int, mixed>
- Fetches the ids of the subcategories from the passed parent category.
Properties
$categoryFactory
Category factory.
protected
CategoryFactoryInterface
$categoryFactory
$db
Database connector.
protected
CI_DB_query_builder
$db
Methods
__construct()
CategoryRepositoryReader constructor.
public
__construct(CI_DB_query_builder $db, CategoryFactoryInterface $categoryFactory) : mixed
Parameters
- $db : CI_DB_query_builder
-
Database connector.
- $categoryFactory : CategoryFactoryInterface
-
Category factory.
Return values
mixed —getActiveCategoryIdsTree()
Returns an id collection with the ids of the active subcategories.
public
getActiveCategoryIdsTree(IdType $parentCategoryId) : IdCollection
Parameters
- $parentCategoryId : IdType
-
Parent category id.
Return values
IdCollection —getById()
Returns a category.
public
getById(IdType $categoryId) : StoredCategoryInterface
Parameters
- $categoryId : IdType
-
Category ID.
Tags
Return values
StoredCategoryInterface —getByParentId()
Returns all Categories with the provided parent ID.
public
getByParentId(IdType $parentId) : IdCollection
Parameters
- $parentId : IdType
Return values
IdCollection —getCategoryIdsTree()
Returns an id collection with the ids of subcategories.
public
getCategoryIdsTree(IdType $parentCategoryId) : IdCollection
Parameters
- $parentCategoryId : IdType
-
Parent category id.
Return values
IdCollection —_createCategoryByArray()
Creates a category instance.
protected
_createCategoryByArray(array<string|int, mixed> $categoryData, array<string|int, mixed> $categoryDescriptionData) : StoredCategory
Parameters
- $categoryData : array<string|int, mixed>
-
Category query result.
- $categoryDescriptionData : array<string|int, mixed>
-
Category description query result.
Tags
Return values
StoredCategory —Returns the complete category object.
_getActiveCategoryIdsTreeArray()
Fetches the ids of the active subcategories from the passed parent category.
protected
_getActiveCategoryIdsTreeArray(IdType $parentCategoryId) : array<string|int, mixed>
Parameters
- $parentCategoryId : IdType
-
Parent id from category of subcategory ids to be fetched.
Return values
array<string|int, mixed> —Contains unsorted ids of sub categories from passed parent category id.
_getCategoryIdsTreeArray()
Fetches the ids of the subcategories from the passed parent category.
protected
_getCategoryIdsTreeArray(IdType $parentCategoryId) : array<string|int, mixed>
Parameters
- $parentCategoryId : IdType
-
Parent id from category of subcategory ids to be fetched.
Return values
array<string|int, mixed> —Contains unsorted ids of sub categories from passed parent category id.