Documentation

ForumPostReactionContext extends ReactionContext
in package

Provides support for giving and receiving reactions on forum posts.

Tags
author

Aberdeener

version
2.2.0
license

MIT

see

ReactionContext, ReactionContextsManager

Table of Contents

Properties

$_forum_language  : Language

Methods

__construct()  : mixed
deleteReaction()  : void
Delete a reaction given in this context.
determineReceiver()  : User
Determine which User owns the given reactable.
friendlyName()  : string
getAllReactions()  : array<string|int, mixed>
Get all the reactions that have been given to the given reactionable.
getUserGiven()  : array<string|int, mixed>
Get all the reactions that the user has given in this context.
getUserReceived()  : array<string|int, mixed>
Get all the reactions that the user has received in this context.
giveReaction()  : void
Record a reaction being given for a given reactable.
hasReacted()  : false|int
Determine whether the user has reacted to the given reactable.
isEnabled()  : bool
name()  : string
reactionUserIdColumn()  : string
Name of the column which contains the owner of the reactionable object in the reactionables reaction table.
validateReactable()  : false|object
Determine whether the user can react to the given reactable.

Properties

Methods

deleteReaction()

Delete a reaction given in this context.

public deleteReaction(int $reactable_reaction_id) : void
Parameters
$reactable_reaction_id : int

ID of the row in the contexts reactions table to delete.

determineReceiver()

Determine which User owns the given reactable.

public determineReceiver(object $reactable) : User

Used to give them a reaction point.

Parameters
$reactable : object

Reactable object to get the receiver for.

Return values
User —

User who owns the given reactable.

friendlyName()

public friendlyName(Language $language) : string
Parameters
$language : Language

Language to get the friendly name in.

Return values
string —

Friendly name of the reaction context. Used when displaying scores in the Reactions profile widget

getAllReactions()

Get all the reactions that have been given to the given reactionable.

public getAllReactions(int $reactionable_id) : array<string|int, mixed>
Parameters
$reactionable_id : int

ID of the reactionable to get the reactions for.

Return values
array<string|int, mixed> —

Array of reactions that have been given to the given reactionable.

getUserGiven()

Get all the reactions that the user has given in this context.

public getUserGiven(User $user) : array<string|int, mixed>

This should return data from the contexts table which contains the reactionable ID, the reaction ID, and the user ID of the user who gave the reaction.

Parameters
$user : User

User to get the reactions for.

Return values
array<string|int, mixed> —

Array of reactions that the user has given in this context.

getUserReceived()

Get all the reactions that the user has received in this context.

public getUserReceived(User $user) : array<string|int, mixed>

This should return data from the contexts table which contains the reactionable ID, the reaction ID, and the user ID of the user who gave the reaction.

Parameters
$user : User

User to get the reactions for.

Return values
array<string|int, mixed> —

Array of reactions that the user has received in this context.

giveReaction()

Record a reaction being given for a given reactable.

public giveReaction(User $user, User $receiver, Reaction $reaction, int $reactable_id) : void
Parameters
$user : User

User who is giving the reaction.

$receiver : User

User who is receiving the reaction (generally the owner of the reactionable object).

$reaction : Reaction

Reaction to give.

$reactable_id : int

ID of the reactable that the user is reacting to.

hasReacted()

Determine whether the user has reacted to the given reactable.

public hasReacted(User $user, Reaction $reaction, int $reactable_id) : false|int
Parameters
$user : User
$reaction : Reaction
$reactable_id : int
Return values
false|int —

Returns false if the user has not reacted, otherwise returns the reactable reaction ID.

isEnabled()

public isEnabled() : bool
Return values
bool —

Whether this reaction context is enabled. If false, the reaction context will not be available for use.

name()

public name() : string
Return values
string —

Name of the reaction context which should be used when calling the /queries/reactions endpoint as the context parameter.

reactionUserIdColumn()

Name of the column which contains the owner of the reactionable object in the reactionables reaction table.

public reactionUserIdColumn() : string

For example, the profile_wall_posts_reaction table stores the ID of the user who added the reaction as the user_id, whereas forum_post_reactions stores the ID of the user who added the reaction as the user_given.

Return values
string —

Name of the column

validateReactable()

Determine whether the user can react to the given reactable.

public validateReactable(int $reactable_id, User $user) : false|object

Reactable meaning some model that can be reacted to: post, profile post, resource, etc.

Parameters
$reactable_id : int
$user : User
Return values
false|object —

Returns false if the reactable does not exist or is not viewable to the user, otherwise returns the reactable object.


        
On this page

Search results