interface StatisticsStorageInterface (View source)

Provides an interface defining Statistics Storage.

Stores the views per day, total views and timestamp of last view for entities.

Methods

bool
recordView(int $id)

Counts an entity view.

fetchViews(array $ids)

Returns the number of times entities have been viewed.

fetchView(int $id)

Returns the number of times a single entity has been viewed.

array
fetchAll(string $order = 'totalcount', int $limit = 5)

Returns the number of times an entity has been viewed.

bool
deleteViews(int $id)

Delete counts for a specific entity.

resetDayCount()

Reset the day counter for all entities once every day.

int
maxTotalCount()

Returns the highest 'totalcount' value.

Details

bool recordView(int $id)

Counts an entity view.

Parameters

int $id

The ID of the entity to count.

Return Value

bool

TRUE if the entity view has been counted.

StatisticsViewsResult[] fetchViews(array $ids)

Returns the number of times entities have been viewed.

Parameters

array $ids

An array of IDs of entities to fetch the views for.

Return Value

StatisticsViewsResult[]

An array of value objects representing the number of times each entity has been viewed. The array is keyed by entity ID. If an ID does not exist, it will not be present in the array.

StatisticsViewsResult|false fetchView(int $id)

Returns the number of times a single entity has been viewed.

Parameters

int $id

The ID of the entity to fetch the views for.

Return Value

StatisticsViewsResult|false

If the entity exists, a value object representing the number of times if has been viewed. If it does not exist, FALSE is returned.

array fetchAll(string $order = 'totalcount', int $limit = 5)

Returns the number of times an entity has been viewed.

Parameters

string $order

The counter name to order by:

  • 'totalcount' The total number of views.
  • 'daycount' The number of views today.
  • 'timestamp' The unix timestamp of the last view.
int $limit

The number of entity IDs to return.

Return Value

array

An ordered array of entity IDs.

bool deleteViews(int $id)

Delete counts for a specific entity.

Parameters

int $id

The ID of the entity which views to delete.

Return Value

bool

TRUE if the entity views have been deleted.

resetDayCount()

Reset the day counter for all entities once every day.

int maxTotalCount()

Returns the highest 'totalcount' value.

Return Value

int

The highest 'totalcount' value.