CategoryService
extends Service
in package
Uses
ServiceTrait, RelatedItemsTrait
This is the category service class.
This class will retrieve the categories from LogiCommerce API and transform them to objects. All the needed category operations previous to Framework must be done here.
Tags
Table of Contents
DELETE | = \SDK\Core\Enums\MethodType::DELETE | |
---|---|---|
GET | = \SDK\Core\Enums\MethodType::GET | |
ITEMS | = 'items' | |
POST | = \SDK\Core\Enums\MethodType::POST | |
PUT | = \SDK\Core\Enums\MethodType::PUT | |
addGetCategories() | Add the request to get the categories filtered with the given parameters | : void |
addGetCategoriesTree() | Add the request to get the categories tree filtered with the given parameters | : void |
addGetCategory() | Add the request to get the category identified by the given id | : void |
addGetCategoryRichSnippets() | Add the request to get the rich snippets for the category identified by the given id | : void |
addGetRelatedItems() | Add the request to get the related items assigned to the given item id | : void |
getCategories() | Returns the categories filtered with the given parameters | : ElementCollection|null |
getCategoriesTree() | Returns the categories tree filtered with the given parameters | : ElementCollection|null |
getCategory() | Returns the category identified by the given id | : Category|null |
getCategoryRichSnippets() | Returns the rich snippets for the category identified by the given id | : CategoryRichSnippets|null |
getInstance() | Returns the requested model instance. | : Service |
getRelatedItems() | Returns the related items assigned to the given item id | : ElementCollection|null |
__construct() | : mixed | |
call() | : array<string|int, mixed> | |
extractParameters() | : array<string|int, mixed> | |
getCollection() | : mixed | |
getConnection() | : Connection | |
getElement() | : Element|null | |
getElements() | : ElementCollection|null | |
getResourceElement() | : Element|null | |
getResponse() | : ElementCollection|null | |
prepareElement() | : Element|null | |
prepareElements() | : array<string|int, mixed> | |
replaceWildcards() | : string |
Constants
DELETE
protected
mixed
DELETE
= \SDK\Core\Enums\MethodType::DELETE
GET
protected
mixed
GET
= \SDK\Core\Enums\MethodType::GET
ITEMS
protected
mixed
ITEMS
= 'items'
POST
protected
mixed
POST
= \SDK\Core\Enums\MethodType::POST
PUT
protected
mixed
PUT
= \SDK\Core\Enums\MethodType::PUT
Methods
addGetCategories()
Add the request to get the categories filtered with the given parameters
public
addGetCategories(BatchRequests $batchRequests, string $batchName[, CategoryParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : CategoryParametersGroup = null
-
object with the needed filters to send to the API categories resource
Return values
void —addGetCategoriesTree()
Add the request to get the categories tree filtered with the given parameters
public
addGetCategoriesTree(BatchRequests $batchRequests, string $batchName[, CategoriesTreeParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : CategoriesTreeParametersGroup = null
-
object with the needed filters to send to the API categories tree resource
Return values
void —addGetCategory()
Add the request to get the category identified by the given id
public
addGetCategory(BatchRequests $batchRequests, string $batchName, int $id) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
Return values
void —addGetCategoryRichSnippets()
Add the request to get the rich snippets for the category identified by the given id
public
addGetCategoryRichSnippets(BatchRequests $batchRequests, string $batchName, int $id) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
Return values
void —addGetRelatedItems()
Add the request to get the related items assigned to the given item id
public
addGetRelatedItems(BatchRequests $batchRequests, string $batchName, int $id[, string $type = '' ][, RelatedItemsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $type : string = ''
-
Optional. This param will set the kind of related we want to retrieve. Valid values are inside RelatedItemsType class. If not given all the related items will be returned inside the RelatedItems object.
- $params : RelatedItemsParametersGroup = null
-
object with the needed filters to send to the API resource
Tags
Return values
void —getCategories()
Returns the categories filtered with the given parameters
public
getCategories([CategoryParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : CategoryParametersGroup = null
-
object with the needed filters to send to the API categories resource
Return values
ElementCollection|null —getCategoriesTree()
Returns the categories tree filtered with the given parameters
public
getCategoriesTree([CategoriesTreeParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : CategoriesTreeParametersGroup = null
-
object with the needed filters to send to the API categories tree resource
Return values
ElementCollection|null —getCategory()
Returns the category identified by the given id
public
getCategory(int $id) : Category|null
Parameters
- $id : int
Return values
Category|null —getCategoryRichSnippets()
Returns the rich snippets for the category identified by the given id
public
getCategoryRichSnippets(int $id) : CategoryRichSnippets|null
Parameters
- $id : int
Return values
CategoryRichSnippets|null —getInstance()
Returns the requested model instance.
public
static getInstance() : Service
If is not setted, this method will set it.
Return values
Service —getRelatedItems()
Returns the related items assigned to the given item id
public
getRelatedItems(int $id[, string $type = '' ][, RelatedItemsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $type : string = ''
-
Optional. This param will set the kind of related we want to retrieve. Valid values are inside RelatedItemsType class. If not given all the related items will be returned inside the RelatedItems object.
- $params : RelatedItemsParametersGroup = null
-
object with the needed filters to send to the API resource
Tags
Return values
ElementCollection|null —__construct()
protected
__construct() : mixed
Return values
mixed —call()
protected
call(Request $request[, string $apiUrl = null ]) : array<string|int, mixed>
Parameters
- $request : Request
- $apiUrl : string = null
Return values
array<string|int, mixed> —extractParameters()
protected
extractParameters([ParametersGroup|null $parametersGroup = null ]) : array<string|int, mixed>
Parameters
- $parametersGroup : ParametersGroup|null = null
Return values
array<string|int, mixed> —getCollection()
protected
getCollection(array<string|int, mixed> $data, string $class) : mixed
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
mixed —getConnection()
protected
getConnection() : Connection
Return values
Connection —getElement()
protected
getElement(string $class, string $resource[, int $id = null ][, mixed $params = null ]) : Element|null
Parameters
- $class : string
- $resource : string
- $id : int = null
- $params : mixed = null
Return values
Element|null —getElements()
protected
getElements(string $class, string $resource[, ParametersGroup $parameters = null ]) : ElementCollection|null
Parameters
- $class : string
- $resource : string
- $parameters : ParametersGroup = null
Return values
ElementCollection|null —getResourceElement()
protected
getResourceElement(string $class, string $resource[, mixed $params = [] ]) : Element|null
Parameters
- $class : string
- $resource : string
- $params : mixed = []
Return values
Element|null —getResponse()
protected
getResponse(array<string|int, mixed> $data, string $class) : ElementCollection|null
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
ElementCollection|null —prepareElement()
protected
prepareElement(array<string|int, mixed> $data, string $class) : Element|null
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
Element|null —prepareElements()
protected
prepareElements(array<string|int, mixed> $data, string $class) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
- $class : string
Return values
array<string|int, mixed> —replaceWildcards()
protected
replaceWildcards(string $resource, array<string|int, mixed> $wildcards) : string
Parameters
- $resource : string
- $wildcards : array<string|int, mixed>