Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
PostHistoryQuery | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
getResults | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | namespace Flow\Formatter; |
4 | |
5 | use Flow\Exception\FlowException; |
6 | use Flow\Model\UUID; |
7 | |
8 | class PostHistoryQuery extends HistoryQuery { |
9 | |
10 | /** |
11 | * @param UUID $postId |
12 | * @param int $limit |
13 | * @param UUID|null $offset |
14 | * @param string $direction 'rev' or 'fwd' |
15 | * @return FormatterRow[] |
16 | */ |
17 | public function getResults( UUID $postId, $limit = 50, ?UUID $offset = null, $direction = 'fwd' ) { |
18 | $history = $this->storage->find( |
19 | 'PostRevision', |
20 | [ 'rev_type_id' => $postId ], |
21 | $this->getOptions( $direction, $limit, $offset ) |
22 | ); |
23 | if ( !$history ) { |
24 | return []; |
25 | } |
26 | |
27 | // See explanation in BoardHistoryQuery::getResults. |
28 | if ( $direction === 'rev' ) { |
29 | $history = array_reverse( $history ); |
30 | } |
31 | |
32 | $this->loadMetadataBatch( $history ); |
33 | $results = []; |
34 | foreach ( $history as $revision ) { |
35 | try { |
36 | $results[] = $row = new FormatterRow; |
37 | $this->buildResult( $revision, null, $row ); |
38 | } catch ( FlowException $e ) { |
39 | \MWExceptionHandler::logException( $e ); |
40 | } |
41 | } |
42 | |
43 | return $results; |
44 | } |
45 | |
46 | } |