Class humhub\modules\user\behaviors\Followable

Inheritancehumhub\modules\user\behaviors\Followable » yii\base\Behavior
Available since version0.5

HFollowableBehavior adds following methods to HActiveRecords

Public Methods

Hide inherited methods

MethodDescriptionDefined By
beforeDelete() humhub\modules\user\behaviors\Followable
follow() Follows the owner object humhub\modules\user\behaviors\Followable
getFollowRecord() Return the follow record based on the owner record and the given user id humhub\modules\user\behaviors\Followable
getFollowerCount() Returns the number of users which are followers of this object. humhub\modules\user\behaviors\Followable
getFollowers() Returns an array of users which are followers of this object. humhub\modules\user\behaviors\Followable
getFollowingCount() Returns the number of follows the owner object performed. humhub\modules\user\behaviors\Followable
getFollowingObjects() Returns an array of object which the owner object follows. humhub\modules\user\behaviors\Followable
isFollowedByUser() Checks if the given user follows this owner record. humhub\modules\user\behaviors\Followable
unfollow() Unfollows the owner object humhub\modules\user\behaviors\Followable

Method Details

beforeDelete() public method

public void beforeDelete ( $event )
$event
follow() public method

Follows the owner object

public boolean follow ( $userId null, $withNotifications true )
$userId integer
$withNotifications boolean

(since 1.2) sets the send_notifications setting of the membership default true

getFollowRecord() public method

Return the follow record based on the owner record and the given user id

public humhub\modules\user\models\Follow getFollowRecord ( $userId )
$userId integer
getFollowerCount() public method

Returns the number of users which are followers of this object.

public integer getFollowerCount ( )
getFollowers() public method

Returns an array of users which are followers of this object.

public \humhub\modules\user\behaviors\Users[]|humhub\modules\user\components\ActiveQueryUser getFollowers ( $query null, $withNotification false, $returnQuery false )
$query
$withNotification
$returnQuery boolean

Only return the query instead of User objects

return \humhub\modules\user\behaviors\Users[]|humhub\modules\user\components\ActiveQueryUser

The user objects or the active query

getFollowingCount() public method

Returns the number of follows the owner object performed.

This is only affects User owner objects!

public integer getFollowingCount ( $objectModel )
$objectModel string

HActiveRecord Classname to restrict Object Classes to (e.g. User)

getFollowingObjects() public method

Returns an array of object which the owner object follows.

This is only affects User owner objects!

E.g. Get list of spaces which are the user follows.

public Array getFollowingObjects ( $query )
$query
isFollowedByUser() public method

Checks if the given user follows this owner record.

Note that the followers for this owner will be cached.

public boolean isFollowedByUser ( $userId null, $withNotifications false )
$userId integer
$withNotifications boolean

If true, only return true when also notifications enabled

return boolean

Is object followed by user

unfollow() public method

Unfollows the owner object

public boolean unfollow ( $userId null )
$userId integer