| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\App\Modules\ImportExportCustomization\Data\Routes; |
| 4 |
|
| 5 |
abstract class Base_Route { |
| 6 |
public function __construct() {} |
| 7 |
|
| 8 |
public function register_route( $namespace, $base_route ): void { |
| 9 |
register_rest_route( $namespace, '/' . $base_route . '/' . $this->get_route(), [ |
| 10 |
[ |
| 11 |
'methods' => $this->get_method(), |
| 12 |
'callback' => fn( $request ) => $this->callback( $request ), |
| 13 |
'permission_callback' => $this->permission_callback(), |
| 14 |
'args' => $this->get_args(), |
| 15 |
], |
| 16 |
] ); |
| 17 |
} |
| 18 |
|
| 19 |
abstract protected function get_route(): string; |
| 20 |
|
| 21 |
abstract protected function get_method(): string; |
| 22 |
|
| 23 |
abstract protected function callback( $request ): \WP_REST_Response; |
| 24 |
|
| 25 |
protected function permission_callback(): callable { |
| 26 |
return fn() => current_user_can( 'manage_options' ); |
| 27 |
} |
| 28 |
|
| 29 |
abstract protected function get_args(): array; |
| 30 |
} |
| 31 |
|