Automattic\WooCommerce\Admin\Features\Blueprint
RestApi::export
Handle the export request.
Method of the class: RestApi{}
No Hooks.
Returns
\WP_HTTP_Response. The response object.
Usage
$RestApi = new RestApi(); $RestApi->export( $request );
- $request(WP_REST_Request) (required)
- The request object.
RestApi::export() RestApi::export code WC 10.5.0
public function export( $request ) {
$payload = $request->get_param( 'steps' );
$steps = $this->steps_payload_to_blueprint_steps( $payload );
$exporter = new ExportSchema();
if ( isset( $payload['plugins'] ) ) {
$exporter->on_before_export(
'installPlugin',
function ( ExportInstallPluginSteps $exporter ) use ( $payload ) {
$exporter->filter(
function ( array $plugins ) use ( $payload ) {
return array_intersect_key( $plugins, array_flip( $payload['plugins'] ) );
}
);
}
);
}
if ( isset( $payload['themes'] ) ) {
$exporter->on_before_export(
'installTheme',
function ( ExportInstallThemeSteps $exporter ) use ( $payload ) {
$exporter->filter(
function ( array $plugins ) use ( $payload ) {
return array_intersect_key( $plugins, array_flip( $payload['themes'] ) );
}
);
}
);
}
$data = $exporter->export( $steps );
if ( is_wp_error( $data ) ) {
return new \WP_REST_Response( $data, 400 );
}
return new \WP_HTTP_Response(
array(
'data' => $data,
'type' => 'json',
)
);
}