1 | <?php |
||
15 | class MediawikiSession implements LoggerAwareInterface { |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $tokens = []; |
||
21 | |||
22 | /** |
||
23 | * @var MediawikiApi |
||
24 | */ |
||
25 | private $api; |
||
26 | |||
27 | /** |
||
28 | * @var bool if this session is running against mediawiki version pre 1.25 |
||
29 | */ |
||
30 | private $usePre125TokensModule = false; |
||
31 | |||
32 | /** |
||
33 | * @var LoggerInterface |
||
34 | */ |
||
35 | private $logger; |
||
36 | |||
37 | /** |
||
38 | * @param MediawikiApi $api The API object to use for this session. |
||
39 | */ |
||
40 | public function __construct( MediawikiApi $api ) { |
||
44 | |||
45 | /** |
||
46 | * Sets a logger instance on the object |
||
47 | * |
||
48 | * @since 1.1 |
||
49 | * |
||
50 | * @param LoggerInterface $logger The new Logger object. |
||
51 | * |
||
52 | * @return null |
||
53 | */ |
||
54 | public function setLogger( LoggerInterface $logger ) { |
||
57 | |||
58 | /** |
||
59 | * Tries to get the specified token from the API |
||
60 | * |
||
61 | * @since 0.1 |
||
62 | * |
||
63 | * @param string $type The type of token to get. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function getToken( $type = 'csrf' ) { |
||
83 | |||
84 | private function reallyGetPre125Token( $type ) { |
||
93 | |||
94 | private function reallyGetToken( $type ) { |
||
116 | |||
117 | /** |
||
118 | * Tries to guess a new token type from an old token type |
||
119 | * |
||
120 | * @param string $type |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | private function getNewTokenType( $type ) { |
||
140 | |||
141 | /** |
||
142 | * Tries to guess an old token type from a new token type |
||
143 | * |
||
144 | * @param string $type |
||
145 | * |
||
146 | * @return string |
||
147 | */ |
||
148 | private function getOldTokenType( $type ) { |
||
154 | |||
155 | /** |
||
156 | * Clears all tokens stored by the api |
||
157 | * |
||
158 | * @since 0.2 |
||
159 | */ |
||
160 | public function clearTokens() { |
||
164 | |||
165 | } |
||
166 |