| 1 |
<?php |
| 2 |
|
| 3 |
namespace ImageOptimizer\Modules\Optimization\Rest; |
| 4 |
|
| 5 |
use ImageOptimizer\Modules\Optimization\Classes\Bulk_Optimization; |
| 6 |
use ImageOptimizer\Modules\Optimization\Classes\Route_Base; |
| 7 |
use Throwable; |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
|
| 13 |
class Get_Bulk_Optimization_Operations extends Route_Base { |
| 14 |
protected string $path = 'bulk/operations'; |
| 15 |
|
| 16 |
public function get_name(): string { |
| 17 |
return 'bulk-optimization-operations'; |
| 18 |
} |
| 19 |
|
| 20 |
public function get_methods(): array { |
| 21 |
return [ 'GET' ]; |
| 22 |
} |
| 23 |
|
| 24 |
public function GET() { |
| 25 |
try { |
| 26 |
$operations = Bulk_Optimization::get_processed_images(); |
| 27 |
|
| 28 |
return $this->respond_success_json([ |
| 29 |
'operations' => $operations, |
| 30 |
]); |
| 31 |
} catch ( Throwable $t ) { |
| 32 |
return $this->respond_error_json([ |
| 33 |
'message' => $t->getMessage(), |
| 34 |
'code' => 'internal_server_error', |
| 35 |
]); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|