interface CommentStatisticsInterface (View source)

Provides an interface for storing and retrieving comment statistics.

Methods

array
getRankingInfo()

Returns an array of ranking information for hook_ranking().

object[]
read(EntityInterface[] $entities, string $entity_type, bool $accurate = TRUE)

Read comment statistics records for an array of entities.

delete(EntityInterface $entity)

Delete comment statistics records for an entity.

update(CommentInterface $comment)

Update or insert comment statistics records after a comment is added.

int
getMaximumCount(string $entity_type)

Find the maximum number of comments for the given entity type.

create(FieldableEntityInterface $entity, array $fields)

Insert an empty record for the given entity.

Details

array getRankingInfo()

Returns an array of ranking information for hook_ranking().

Return Value

array

Array of ranking information as expected by hook_ranking().

See also

hook_ranking()
comment_ranking()

object[] read(EntityInterface[] $entities, string $entity_type, bool $accurate = TRUE)

Read comment statistics records for an array of entities.

Parameters

EntityInterface[] $entities

Array of entities on which commenting is enabled, keyed by id

string $entity_type

The entity type of the passed entities.

bool $accurate

(optional) Indicates if results must be completely up to date. If set to FALSE, a replica database will used if available. Defaults to TRUE.

Return Value

object[]

Array of statistics records.

delete(EntityInterface $entity)

Delete comment statistics records for an entity.

Parameters

EntityInterface $entity

The entity for which comment statistics should be deleted.

update(CommentInterface $comment)

Update or insert comment statistics records after a comment is added.

Parameters

CommentInterface $comment

The comment added or updated.

int getMaximumCount(string $entity_type)

Find the maximum number of comments for the given entity type.

Used to influence search rankings.

Parameters

string $entity_type

The entity type to consider when fetching the maximum comment count for.

Return Value

int

The maximum number of comments for and entity of the given type.

See also

comment_update_index()

create(FieldableEntityInterface $entity, array $fields)

Insert an empty record for the given entity.

Parameters

FieldableEntityInterface $entity

The created entity for which a statistics record is to be initialized.

array $fields

Array of comment field definitions for the given entity.