Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\Store; |
4 | |
5 | use MediaWiki\Status\Status; |
6 | use stdClass; |
7 | use Wikimedia\Rdbms\IDatabase; |
8 | |
9 | /** |
10 | * This is an abstraction of the persistence layer, to allow XML dumps to be |
11 | * operated on and tallied, like elections in the local DB. |
12 | * |
13 | * Most of the UI layer has no need for this abstraction, and so we provide |
14 | * direct database access via getDB() to ease development of those components. |
15 | * The XML store will throw an exception if getDB() is called on it. |
16 | * |
17 | * Most of the functions here are internal interfaces for the use of |
18 | * the entity classes (election, question and option). The entity classes |
19 | * and Context provide methods that are more appropriate for general |
20 | * users. |
21 | */ |
22 | interface Store { |
23 | /** |
24 | * Get an array of messages with a given language, and entity IDs |
25 | * in a given array of IDs. The return format is a 2-d array mapping ID |
26 | * and message key to value. |
27 | * @param string $lang |
28 | * @param int[] $ids |
29 | * @return string[][] |
30 | */ |
31 | public function getMessages( $lang, $ids ); |
32 | |
33 | /** |
34 | * Get a list of languages that the given entity IDs have messages for. |
35 | * Returns an array of language codes. |
36 | * @param int[] $ids |
37 | * @return string[] |
38 | */ |
39 | public function getLangList( $ids ); |
40 | |
41 | /** |
42 | * Get an array of properties for a given set of IDs. Returns a 2-d array |
43 | * mapping IDs and property keys to values. |
44 | * @param int[] $ids |
45 | * @return string[][] |
46 | */ |
47 | public function getProperties( $ids ); |
48 | |
49 | /** |
50 | * Get the type of one or more SecurePoll entities. |
51 | * @param int $id |
52 | * @return string|false |
53 | */ |
54 | public function getEntityType( $id ); |
55 | |
56 | /** |
57 | * Get information about a set of elections, specifically the data that |
58 | * is stored in the securepoll_elections row in the DB. Returns a 2-d |
59 | * array mapping ID to associative array of properties. |
60 | * @param int[] $ids |
61 | * @return array[] |
62 | */ |
63 | public function getElectionInfo( $ids ); |
64 | |
65 | /** |
66 | * Get election information for a given set of names. |
67 | * @param array $names |
68 | * @return array[] |
69 | */ |
70 | public function getElectionInfoByTitle( $names ); |
71 | |
72 | /** |
73 | * Convert a row from the securepoll_elections table into an associative |
74 | * array suitable for return by getElectionInfo(). |
75 | * @param stdClass $row |
76 | * @return array |
77 | */ |
78 | public function decodeElectionRow( $row ); |
79 | |
80 | /** |
81 | * Get a database connection object. |
82 | * @param int $index DB_PRIMARY or DB_REPLICA |
83 | * @return IDatabase |
84 | */ |
85 | public function getDB( $index = DB_PRIMARY ); |
86 | |
87 | /** |
88 | * Set a flag which, if true, forces subsequent calls to getDB() to return |
89 | * a primary connection even if $index is DB_REPLICA. |
90 | * |
91 | * @param bool $forcePrimary |
92 | */ |
93 | public function setForcePrimary( $forcePrimary ); |
94 | |
95 | /** |
96 | * Get an associative array of information about all questions in a given |
97 | * election. |
98 | * @param int $electionId |
99 | * @return array[] |
100 | */ |
101 | public function getQuestionInfo( $electionId ); |
102 | |
103 | /** |
104 | * Call a callback function for all valid votes with a given election ID. |
105 | * @param int $electionId |
106 | * @param callable $callback |
107 | * @param int|null $voterId Optional, only used by some implementations |
108 | * @return Status |
109 | */ |
110 | public function callbackValidVotes( $electionId, $callback, $voterId = null ); |
111 | } |