| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
*/ |
| 5 |
|
| 6 |
namespace WP_Syntex\Polylang\REST; |
| 7 |
|
| 8 |
use WP_Error; |
| 9 |
use WP_REST_Controller; |
| 10 |
|
| 11 |
defined( 'ABSPATH' ) || exit; |
| 12 |
|
| 13 |
/** |
| 14 |
* Abstract REST controller. |
| 15 |
* |
| 16 |
* @since 3.7 |
| 17 |
*/ |
| 18 |
abstract class Abstract_Controller extends WP_REST_Controller { |
| 19 |
/** |
| 20 |
* Adds a status code to the given error and returns the error. |
| 21 |
* |
| 22 |
* @since 3.7 |
| 23 |
* |
| 24 |
* @param WP_Error $error A `WP_Error` object. |
| 25 |
* @param int $status_code Optional. A status code. Default is 400. |
| 26 |
* @return WP_Error |
| 27 |
*/ |
| 28 |
protected function add_status_to_error( WP_Error $error, int $status_code = 400 ): WP_Error { |
| 29 |
$error->add_data( array( 'status' => $status_code ) ); |
| 30 |
return $error; |
| 31 |
} |
| 32 |
} |
| 33 |
|