Commit de7ff45
authored
[Data Liberation] Filesystem entity reader (#2125)
A part of #1894
Adds a new API for loading content from a WP_Filesystem instance:
* `WP_Filesystem_To_Post_Tree` for traversing a directory tree and
mapping the structure a hierarchical WordPress post/meta entity stream
* `WP_Filesystem_Entity_Reader` for converting the raw file content into
WordPress blocks
To convert a set of zipped files into WordPress entities:
```php
// Any Filesystem instance works here. Could be WP_Local_Filesystem,
// WP_Git_Filesystem, or anything else. Let's read from a zip file here:
$fs = new WP_Zip_Filesystem(
WP_File_Reader::create('./docs.zip')
);
$reader = new WP_Filesystem_Entity_Reader( $fs );
foreach($reader as $entity) {
var_dump($entity);
}
```
## Testing
The code isn't used anywhere yet – just rely on the CI checks.1 parent e4b3c87 commit de7ff45
File tree
11 files changed
+666
-349
lines changed- packages/playground
- data-liberation-markdown/src
- data-liberation
- src
- entity-readers
- import
- tests
- fixtures/filesystem-entity-reader
- nested
11 files changed
+666
-349
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
53 | 61 | | |
0 commit comments