Skip to content

Commit a46edf9

Browse files
committed
Add docstrings and a missing constant
1 parent 1c66dd0 commit a46edf9

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

packages/playground/data-liberation/src/entity-readers/WP_HTML_Entity_Reader.php

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
<?php
22

3-
use WordPress\Data_Liberation\Block_Markup\WP_HTML_To_Blocks;
4-
53
/**
6-
* Converts a single HTML file into a stream of WordPress entities.
7-
*
8-
* @TODO: Support post meta.
4+
* Converts a single HTML file into a stream of WordPress posts and post meta.
95
*/
106
class WP_HTML_Entity_Reader extends WP_Entity_Reader {
117

@@ -19,6 +15,11 @@ public function __construct( $html, $post_id ) {
1915
$this->post_id = $post_id;
2016
}
2117

18+
/**
19+
* Advances to the next entity.
20+
*
21+
* @return bool Whether the next entity was found.
22+
*/
2223
public function next_entity() {
2324
// If we're finished, we're finished.
2425
if ( $this->finished ) {
@@ -78,17 +79,32 @@ public function next_entity() {
7879
return true;
7980
}
8081

82+
/**
83+
* Returns the current entity.
84+
*
85+
* @return WP_Imported_Entity|false The current entity, or false if there are no entities left.
86+
*/
8187
public function get_entity() {
8288
if ( $this->is_finished() ) {
8389
return false;
8490
}
8591
return $this->entities[0];
8692
}
8793

94+
/**
95+
* Checks if this reader has finished yet.
96+
*
97+
* @return bool Whether the reader has finished.
98+
*/
8899
public function is_finished(): bool {
89100
return $this->finished;
90101
}
91102

103+
/**
104+
* Returns the last error that occurred when processing the HTML.
105+
*
106+
* @return string|null The last error, or null if there was no error.
107+
*/
92108
public function get_last_error(): ?string {
93109
return null;
94110
}

packages/playground/data-liberation/src/import/WP_Imported_Entity.php

+30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<?php
22

3+
/**
4+
* Represents a single entity, whether a WordPress post, post meta,
5+
* a single SQL record, or something entirely different.
6+
*/
37
class WP_Imported_Entity {
48

59
const TYPE_POST = 'post';
@@ -12,6 +16,32 @@ class WP_Imported_Entity {
1216
const TYPE_USER = 'user';
1317
const TYPE_SITE_OPTION = 'site_option';
1418

19+
const POST_FIELDS = array(
20+
'post_title',
21+
'link',
22+
'guid',
23+
'post_excerpt',
24+
'post_published_at',
25+
'post_author',
26+
'post_content',
27+
'post_excerpt',
28+
'post_id',
29+
'post_status',
30+
'post_date',
31+
'post_date_gmt',
32+
'post_modified',
33+
'post_modified_gmt',
34+
'comment_status',
35+
'ping_status',
36+
'post_name',
37+
'post_parent',
38+
'menu_order',
39+
'post_type',
40+
'post_password',
41+
'is_sticky',
42+
'attachment_url',
43+
);
44+
1545
private $type;
1646
private $data;
1747

0 commit comments

Comments
 (0)