Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data Liberation] Filesystem entity reader #2125

Merged
merged 4 commits into from
Jan 10, 2025
Merged

Conversation

adamziel
Copy link
Collaborator

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:

// 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.

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.
@adamziel adamziel merged commit de7ff45 into trunk Jan 10, 2025
10 checks passed
@adamziel adamziel deleted the filesystem-reader branch January 10, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant