Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
BaseTopicListFormatter | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
buildEmptyResult | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
buildPaginationLinks | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace Flow\Formatter; |
4 | |
5 | use Flow\Model\Anchor; |
6 | use Flow\Model\Workflow; |
7 | |
8 | class BaseTopicListFormatter { |
9 | /** |
10 | * Builds the results for an empty topic. |
11 | * |
12 | * @param Workflow $workflow Workflow for topic list |
13 | * @return array Associative array with the result |
14 | */ |
15 | public function buildEmptyResult( Workflow $workflow ) { |
16 | return [ |
17 | 'type' => 'topiclist', |
18 | 'roots' => [], |
19 | 'posts' => [], |
20 | 'revisions' => [], |
21 | 'links' => [ 'pagination' => [] ], |
22 | ]; |
23 | } |
24 | |
25 | /** |
26 | * @param Workflow $workflow Topic list workflow |
27 | * @param array[] $links pagination link data |
28 | * |
29 | * @return Anchor[] link structure |
30 | */ |
31 | protected function buildPaginationLinks( Workflow $workflow, array $links ) { |
32 | $res = []; |
33 | $title = $workflow->getArticleTitle(); |
34 | foreach ( $links as $key => $options ) { |
35 | // prefix all options with topiclist_ |
36 | $realOptions = []; |
37 | foreach ( $options as $k => $v ) { |
38 | $realOptions["topiclist_$k"] = $v; |
39 | } |
40 | $res[$key] = new Anchor( |
41 | $key, // @todo i18n |
42 | $title, |
43 | $realOptions |
44 | ); |
45 | } |
46 | |
47 | return $res; |
48 | } |
49 | } |