Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PageRevisionedObject | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionData | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
getRevisions | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Flow\Import\LiquidThreadsApi; |
4 | |
5 | use Flow\Import\IRevisionableObject; |
6 | |
7 | abstract class PageRevisionedObject implements IRevisionableObject { |
8 | /** @var int */ |
9 | protected $pageId; |
10 | |
11 | /** |
12 | * @var ImportSource |
13 | */ |
14 | protected $importSource; |
15 | |
16 | /** |
17 | * @param ImportSource $source |
18 | * @param int $pageId ID of the remote page |
19 | */ |
20 | public function __construct( $source, $pageId ) { |
21 | $this->importSource = $source; |
22 | $this->pageId = $pageId; |
23 | } |
24 | |
25 | /** |
26 | * Gets the raw revisions, after filtering but before being converted to |
27 | * ImportRevision. |
28 | * |
29 | * @return array Page data with filtered revisions |
30 | */ |
31 | protected function getRevisionData() { |
32 | $pageData = $this->importSource->getPageData( $this->pageId ); |
33 | // filter revisions without content (deleted) |
34 | foreach ( $pageData['revisions'] as $key => $value ) { |
35 | if ( isset( $value['texthidden'] ) ) { |
36 | unset( $pageData['revisions'][$key] ); |
37 | } |
38 | } |
39 | // the iterators expect this to be a 0 indexed list |
40 | $pageData['revisions'] = array_values( $pageData['revisions'] ); |
41 | return $pageData; |
42 | } |
43 | |
44 | public function getRevisions() { |
45 | $pageData = $this->getRevisionData(); |
46 | $scriptUser = $this->importSource->getScriptUser(); |
47 | return new RevisionIterator( $pageData, $this, static function ( $data, $parent ) use ( $scriptUser ) { |
48 | return new ImportRevision( $data, $parent, $scriptUser ); |
49 | } ); |
50 | } |
51 | } |