| 1 |
<?php |
| 2 |
|
| 3 |
namespace Upress\EzCache\Rest; |
| 4 |
|
| 5 |
use Upress\EzCache\Preload; |
| 6 |
use WP_REST_Request; |
| 7 |
|
| 8 |
class PreloadController { |
| 9 |
|
| 10 |
/** |
| 11 |
* Get the current state of the preload queue. |
| 12 |
*/ |
| 13 |
public function show() { |
| 14 |
return wp_send_json_success( Preload::instance()->get_status() ); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Start (or restart) the preload process. |
| 19 |
* |
| 20 |
* @param WP_REST_Request $request |
| 21 |
*/ |
| 22 |
public function start( $request ) { |
| 23 |
$status = Preload::instance()->start(); |
| 24 |
|
| 25 |
return wp_send_json_success( $status ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Cancel a running preload. |
| 30 |
*/ |
| 31 |
public function destroy() { |
| 32 |
$status = Preload::instance()->stop(); |
| 33 |
|
| 34 |
return wp_send_json_success( $status ); |
| 35 |
} |
| 36 |
} |
| 37 |
|