3 namespace Drupal\statistics;
6 * Provides an interface defining Statistics Storage.
8 * Stores the views per day, total views and timestamp of last view
11 interface StatisticsStorageInterface {
14 * Count a entity view.
17 * The ID of the entity to count.
20 * TRUE if the entity view has been counted.
22 public function recordView($id);
25 * Returns the number of times entities have been viewed.
28 * An array of IDs of entities to fetch the views for.
30 * @return \Drupal\statistics\StatisticsViewsResult[]
31 * An array of value objects representing the number of times each entity
32 * has been viewed. The array is keyed by entity ID. If an ID does not
33 * exist, it will not be present in the array.
35 public function fetchViews($ids);
38 * Returns the number of times a single entity has been viewed.
41 * The ID of the entity to fetch the views for.
43 * @return \Drupal\statistics\StatisticsViewsResult|false
44 * If the entity exists, a value object representing the number of times if
45 * has been viewed. If it does not exist, FALSE is returned.
47 public function fetchView($id);
50 * Returns the number of times a entity has been viewed.
52 * @param string $order
53 * The counter name to order by:
54 * - 'totalcount' The total number of views.
55 * - 'daycount' The number of views today.
56 * - 'timestamp' The unix timestamp of the last view.
59 * The number of entity IDs to return.
62 * An ordered array of entity IDs.
64 public function fetchAll($order = 'totalcount', $limit = 5);
67 * Delete counts for a specific entity.
70 * The ID of the entity which views to delete.
73 * TRUE if the entity views have been deleted.
75 public function deleteViews($id);
78 * Reset the day counter for all entities once every day.
80 public function resetDayCount();
83 * Returns the highest 'totalcount' value.
86 * The highest 'totalcount' value.
88 public function maxTotalCount();