BlogService
extends Service
in package
Uses
ServiceTrait, RelatedItemsTrait
This is the blog service class.
This class will retrieve the blogs from LogiCommerce API and transform them to objects. All the needed blog 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 | |
addGetBlogCategories() | Add the request to get the blog categories filtered with the given parameters | : void |
addGetBlogCategory() | Add the request to get the blog category identified by the given id | : void |
addGetBlogger() | Add the request to get the blog blogger identified by the given id | : void |
addGetBloggers() | Add the request to get the blog bloggers filtered with the given parameters | : void |
addGetBlogPost() | Add the request to get the blog post identified by the given id | : void |
addGetBlogPostComments() | Add the request to get the blog post comments filtered with the given parameters | : void |
addGetBlogPosts() | Add the request to get the blog posts filtered with the given parameters | : void |
addGetRelatedItems() | Add the request to get the related items assigned to the given item id | : void |
addGetRss() | Add the request to get the blog rss filtered with the given parameters | : void |
addGetTag() | Add the request to get the blog tag identified by the given id | : void |
addGetTags() | Add the request to get the blog tags filtered with the given parameters | : void |
categorySubscribe() | Subscribe the current user to the blog category that matches the given id. | : Status|null |
categoryUnsubscribe() | Unsubscribe the current user to the blog category that matches the given id. | : Status|null |
getBlogCategories() | Returns the blog categories filtered with the given parameters | : ElementCollection|null |
getBlogCategory() | Returns the blog category identified by the given id | : BlogCategory|null |
getBlogger() | Returns the blog blogger identified by the given id | : Blogger|null |
getBloggers() | Returns the blog bloggers filtered with the given parameters | : ElementCollection|null |
getBlogPost() | Returns the blog post identified by the given id | : BlogPost|null |
getBlogPostComments() | Returns the blog post comments filtered with the given parameters | : ElementCollection|null |
getBlogPosts() | Returns the blog posts filtered with the given parameters | : ElementCollection|null |
getInstance() | Returns the requested model instance. | : Service |
getRelatedItems() | Returns the related items assigned to the given item id | : ElementCollection|null |
getRss() | Returns the blog rss filtered with the given parameters | : ElementCollection|null |
getTag() | Returns the blog tag identified by the given id | : BlogTag|null |
getTags() | Returns the blog tags filtered with the given parameters | : ElementCollection|null |
postAddComment() | Add a new comment into the blog post that matches the given id | : BlogPostComment|null |
postDeleteDislike() | Delete a dislike into the blog post that matches the given id | : Status|null |
postDeleteLike() | Delete a like into the blog post that matches the given id | : Status|null |
postDislike() | Add a dislike into the blog post that matches the given id | : Status|null |
postDoneHit() | Increase the post that matches the given id hit counter | : Status|null |
postLike() | Add a like into the blog post that matches the given id | : Status|null |
postRate() | Add a rating into the blog post that matches the given id | : Status|null |
postSubscribe() | Subscribe the current user to the blog post that matches the given id. | : Status|null |
postUnsubscribe() | Unsubscribe the current user to the blog post that matches the given id. | : Status|null |
subscribe() | Subscribe the current user to the blog. | : Status|null |
unsubscribe() | Unsubscribe the current user to the blog. | : Status|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
addGetBlogCategories()
Add the request to get the blog categories filtered with the given parameters
public
addGetBlogCategories(BatchRequests $batchRequests, string $batchName[, BlogCategoryParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : BlogCategoryParametersGroup = null
Return values
void —addGetBlogCategory()
Add the request to get the blog category identified by the given id
public
addGetBlogCategory(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 —addGetBlogger()
Add the request to get the blog blogger identified by the given id
public
addGetBlogger(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 —addGetBloggers()
Add the request to get the blog bloggers filtered with the given parameters
public
addGetBloggers(BatchRequests $batchRequests, string $batchName[, BloggerParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : BloggerParametersGroup = null
Return values
void —addGetBlogPost()
Add the request to get the blog post identified by the given id
public
addGetBlogPost(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 —addGetBlogPostComments()
Add the request to get the blog post comments filtered with the given parameters
public
addGetBlogPostComments(BatchRequests $batchRequests, string $batchName, int $id[, BlogPostCommentsParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $id : int
- $params : BlogPostCommentsParametersGroup = null
Return values
void —addGetBlogPosts()
Add the request to get the blog posts filtered with the given parameters
public
addGetBlogPosts(BatchRequests $batchRequests, string $batchName[, BlogPostParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : BlogPostParametersGroup = null
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 —addGetRss()
Add the request to get the blog rss filtered with the given parameters
public
addGetRss(BatchRequests $batchRequests, string $batchName[, BlogPostParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : BlogPostParametersGroup = null
Return values
void —addGetTag()
Add the request to get the blog tag identified by the given id
public
addGetTag(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 —addGetTags()
Add the request to get the blog tags filtered with the given parameters
public
addGetTags(BatchRequests $batchRequests, string $batchName[, BlogTagParametersGroup $params = null ]) : void
Parameters
- $batchRequests : BatchRequests
- $batchName : string
-
the name that will identify the request on the batch return.
- $params : BlogTagParametersGroup = null
Return values
void —categorySubscribe()
Subscribe the current user to the blog category that matches the given id.
public
categorySubscribe(int $id[, string $email = '' ]) : Status|null
If no user is loged in, email is required.
Parameters
- $id : int
- $email : string = ''
Return values
Status|null —categoryUnsubscribe()
Unsubscribe the current user to the blog category that matches the given id.
public
categoryUnsubscribe(int $id[, string $hash = '' ]) : Status|null
If no user is loged in, email is required.
Parameters
- $id : int
- $hash : string = ''
Return values
Status|null —getBlogCategories()
Returns the blog categories filtered with the given parameters
public
getBlogCategories([BlogCategoryParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : BlogCategoryParametersGroup = null
-
object with the needed filters to send to the API blogs resource
Return values
ElementCollection|null —getBlogCategory()
Returns the blog category identified by the given id
public
getBlogCategory(int $id) : BlogCategory|null
Parameters
- $id : int
Return values
BlogCategory|null —getBlogger()
Returns the blog blogger identified by the given id
public
getBlogger(int $id) : Blogger|null
Parameters
- $id : int
Return values
Blogger|null —getBloggers()
Returns the blog bloggers filtered with the given parameters
public
getBloggers([BloggerParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : BloggerParametersGroup = null
-
object with the needed filters to send to the API blogs resource
Return values
ElementCollection|null —getBlogPost()
Returns the blog post identified by the given id
public
getBlogPost(int $id) : BlogPost|null
Parameters
- $id : int
Return values
BlogPost|null —getBlogPostComments()
Returns the blog post comments filtered with the given parameters
public
getBlogPostComments(int $id[, BlogPostCommentsParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $id : int
- $params : BlogPostCommentsParametersGroup = null
-
object with the needed filters to send to the API posts/comments resource
Return values
ElementCollection|null —getBlogPosts()
Returns the blog posts filtered with the given parameters
public
getBlogPosts([BlogPostParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : BlogPostParametersGroup = null
-
object with the needed filters to send to the API blogs resource
Return values
ElementCollection|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 —getRss()
Returns the blog rss filtered with the given parameters
public
getRss([BlogPostParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : BlogPostParametersGroup = null
-
object with the needed filters to send to the API blogs resource
Return values
ElementCollection|null —getTag()
Returns the blog tag identified by the given id
public
getTag(int $id) : BlogTag|null
Parameters
- $id : int
Return values
BlogTag|null —getTags()
Returns the blog tags filtered with the given parameters
public
getTags([BlogTagParametersGroup $params = null ]) : ElementCollection|null
Parameters
- $params : BlogTagParametersGroup = null
-
object with the needed filters to send to the API blogs resource
Return values
ElementCollection|null —postAddComment()
Add a new comment into the blog post that matches the given id
public
postAddComment(int $id[, AddBlogPostCommentParametersGroup $comment = null ]) : BlogPostComment|null
Parameters
- $id : int
- $comment : AddBlogPostCommentParametersGroup = null
-
object with the needed data to add a new comment
Return values
BlogPostComment|null —postDeleteDislike()
Delete a dislike into the blog post that matches the given id
public
postDeleteDislike(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —postDeleteLike()
Delete a like into the blog post that matches the given id
public
postDeleteLike(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —postDislike()
Add a dislike into the blog post that matches the given id
public
postDislike(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —postDoneHit()
Increase the post that matches the given id hit counter
public
postDoneHit(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —postLike()
Add a like into the blog post that matches the given id
public
postLike(int $id) : Status|null
Parameters
- $id : int
Return values
Status|null —postRate()
Add a rating into the blog post that matches the given id
public
postRate(int $id, int $rating) : Status|null
Parameters
- $id : int
- $rating : int
-
(must be into the 0-5 range)
Return values
Status|null —postSubscribe()
Subscribe the current user to the blog post that matches the given id.
public
postSubscribe(int $id[, string $email = '' ]) : Status|null
If no user is loged in, email is required.
Parameters
- $id : int
- $email : string = ''
Return values
Status|null —postUnsubscribe()
Unsubscribe the current user to the blog post that matches the given id.
public
postUnsubscribe(int $id[, string $hash = '' ]) : Status|null
If no user is loged in, email is required.
Parameters
- $id : int
- $hash : string = ''
Return values
Status|null —subscribe()
Subscribe the current user to the blog.
public
subscribe([string $email = '' ]) : Status|null
If no user is loged in, email is required.
Parameters
- $email : string = ''
Return values
Status|null —unsubscribe()
Unsubscribe the current user to the blog.
public
unsubscribe([string $hash = '' ]) : Status|null
If no user is loged in, hash is required.
Parameters
- $hash : string = ''
Return values
Status|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>