Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SinglePostQuery | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| getResult | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Flow\Formatter; |
| 4 | |
| 5 | use Flow\Exception\FlowException; |
| 6 | use Flow\Model\UUID; |
| 7 | |
| 8 | class SinglePostQuery extends AbstractQuery { |
| 9 | /** |
| 10 | * @param UUID $postId |
| 11 | * @return FormatterRow |
| 12 | * @throws FlowException |
| 13 | */ |
| 14 | public function getResult( UUID $postId ) { |
| 15 | $found = $this->storage->find( |
| 16 | 'PostRevision', |
| 17 | [ 'rev_type_id' => $postId ], |
| 18 | [ 'sort' => 'rev_id', 'order' => 'DESC', 'limit' => 1 ] |
| 19 | ); |
| 20 | if ( !$found ) { |
| 21 | throw new FlowException( '@todo' ); |
| 22 | } |
| 23 | $this->loadMetadataBatch( $found ); |
| 24 | |
| 25 | $formatterRow = null; |
| 26 | $post = reset( $found ); |
| 27 | // Summary is only available to topic title now |
| 28 | if ( $post->isTopicTitle() ) { |
| 29 | $summary = $this->storage->find( |
| 30 | 'PostSummary', |
| 31 | [ 'rev_type_id' => $postId ], |
| 32 | [ 'sort' => 'rev_id', 'order' => 'DESC', 'limit' => 1 ] |
| 33 | ); |
| 34 | if ( $summary ) { |
| 35 | $formatterRow = new TopicRow(); |
| 36 | $formatterRow->summary = $this->buildResult( reset( $summary ), 'rev_id' ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return $this->buildResult( $post, null, $formatterRow ); |
| 41 | } |
| 42 | } |