Merge pull request #18118 from artfulrobot/artfulrobot-msgtpl-disable-smarty
[civicrm-core.git] / CRM / Core / PrevNextCache / Interface.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Interface CRM_Core_PrevNextCache_Interface
14 *
15 * The previous/next cache is a service for tracking query results. Results
16 * are stored in a cache, and they may be individually toggled.
17 */
18 interface CRM_Core_PrevNextCache_Interface {
19
20 /**
21 * Store the results of a SQL query in the cache.
22 *
23 * @param string $cacheKey
24 * @param string $sql
25 * A SQL query. The query *MUST* be a SELECT statement which yields
26 * the following columns (in order): cachekey, entity_id1, data
27 * @param array $sqlParams
28 * An array of parameters to be used with $sql.
29 * Use the same interpolation format as CRM_Core_DAO (composeQuery/executeQuery).
30 * Ex: [1 => ['foo', 'String']]
31 * @return bool
32 * @see CRM_Core_DAO::composeQuery
33 */
34 public function fillWithSql($cacheKey, $sql, $sqlParams = []);
35
36 /**
37 * Store the contents of an array in the cache.
38 *
39 * @param string $cacheKey
40 * @param array $rows
41 * A list of cache records. Each record should have keys:
42 * - entity_id1
43 * - data
44 * @return bool
45 */
46 public function fillWithArray($cacheKey, $rows);
47
48 /**
49 * Save checkbox selections.
50 *
51 * @param string $cacheKey
52 * @param string $action
53 * Ex: 'select', 'unselect'.
54 * @param array|int|null $ids
55 * A list of contact IDs to (un)select.
56 * To unselect all contact IDs, use NULL.
57 */
58 public function markSelection($cacheKey, $action, $ids = NULL);
59
60 /**
61 * Get the selections.
62 *
63 * @param string $cacheKey
64 * Cache key.
65 * @param string $action
66 * One of the following:
67 * - 'get' - get only selection records
68 * - 'getall' - get all the records of the specified cache key
69 *
70 * @return array|NULL
71 */
72 public function getSelection($cacheKey, $action = 'get');
73
74 /**
75 * Get the previous and next keys.
76 *
77 * @param string $cacheKey
78 * @param int $id1
79 *
80 * @return array
81 * List of neighbors.
82 * [
83 * 'foundEntry' => 1,
84 * 'prev' => ['id1' => 123, 'data'=>'foo'],
85 * 'next' => ['id1' => 456, 'data'=>'foo'],
86 * ]
87 */
88 public function getPositions($cacheKey, $id1);
89
90 /**
91 * Delete an item from the prevnext cache table based on the entity.
92 *
93 * @param int $id
94 * @param string $cacheKey
95 */
96 public function deleteItem($id = NULL, $cacheKey = NULL);
97
98 /**
99 * Get count of matching rows.
100 *
101 * @param string $cacheKey
102 * @return int
103 */
104 public function getCount($cacheKey);
105
106 /**
107 * Fetch a list of contacts from the prev/next cache for displaying a search results page
108 *
109 * @param string $cacheKey
110 * @param int $offset
111 * @param int $rowCount
112 * @return array
113 * List of contact IDs (entity_id1).
114 */
115 public function fetch($cacheKey, $offset, $rowCount);
116
117 /**
118 * Remove items from prev/next cache no longer current
119 */
120 public function cleanup();
121
122 }