annotate core/modules/statistics/src/StatisticsStorageInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\statistics;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Provides an interface defining Statistics Storage.
Chris@0 7 *
Chris@0 8 * Stores the views per day, total views and timestamp of last view
Chris@0 9 * for entities.
Chris@0 10 */
Chris@0 11 interface StatisticsStorageInterface {
Chris@0 12
Chris@0 13 /**
Chris@0 14 * Count a entity view.
Chris@0 15 *
Chris@0 16 * @param int $id
Chris@0 17 * The ID of the entity to count.
Chris@0 18 *
Chris@0 19 * @return bool
Chris@0 20 * TRUE if the entity view has been counted.
Chris@0 21 */
Chris@0 22 public function recordView($id);
Chris@0 23
Chris@0 24 /**
Chris@0 25 * Returns the number of times entities have been viewed.
Chris@0 26 *
Chris@0 27 * @param array $ids
Chris@0 28 * An array of IDs of entities to fetch the views for.
Chris@0 29 *
Chris@0 30 * @return \Drupal\statistics\StatisticsViewsResult[]
Chris@0 31 * An array of value objects representing the number of times each entity
Chris@0 32 * has been viewed. The array is keyed by entity ID. If an ID does not
Chris@0 33 * exist, it will not be present in the array.
Chris@0 34 */
Chris@0 35 public function fetchViews($ids);
Chris@0 36
Chris@0 37 /**
Chris@0 38 * Returns the number of times a single entity has been viewed.
Chris@0 39 *
Chris@0 40 * @param int $id
Chris@0 41 * The ID of the entity to fetch the views for.
Chris@0 42 *
Chris@0 43 * @return \Drupal\statistics\StatisticsViewsResult|false
Chris@0 44 * If the entity exists, a value object representing the number of times if
Chris@0 45 * has been viewed. If it does not exist, FALSE is returned.
Chris@0 46 */
Chris@0 47 public function fetchView($id);
Chris@0 48
Chris@0 49 /**
Chris@0 50 * Returns the number of times a entity has been viewed.
Chris@0 51 *
Chris@0 52 * @param string $order
Chris@0 53 * The counter name to order by:
Chris@0 54 * - 'totalcount' The total number of views.
Chris@0 55 * - 'daycount' The number of views today.
Chris@0 56 * - 'timestamp' The unix timestamp of the last view.
Chris@0 57 *
Chris@0 58 * @param int $limit
Chris@0 59 * The number of entity IDs to return.
Chris@0 60 *
Chris@0 61 * @return array
Chris@0 62 * An ordered array of entity IDs.
Chris@0 63 */
Chris@0 64 public function fetchAll($order = 'totalcount', $limit = 5);
Chris@0 65
Chris@0 66 /**
Chris@0 67 * Delete counts for a specific entity.
Chris@0 68 *
Chris@0 69 * @param int $id
Chris@0 70 * The ID of the entity which views to delete.
Chris@0 71 *
Chris@0 72 * @return bool
Chris@0 73 * TRUE if the entity views have been deleted.
Chris@0 74 */
Chris@0 75 public function deleteViews($id);
Chris@0 76
Chris@0 77 /**
Chris@0 78 * Reset the day counter for all entities once every day.
Chris@0 79 */
Chris@0 80 public function resetDayCount();
Chris@0 81
Chris@0 82 /**
Chris@0 83 * Returns the highest 'totalcount' value.
Chris@0 84 *
Chris@0 85 * @return int
Chris@0 86 * The highest 'totalcount' value.
Chris@0 87 */
Chris@0 88 public function maxTotalCount();
Chris@0 89
Chris@0 90 }