| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Controls Router details |
| 5 |
*/ |
| 6 |
|
| 7 |
namespace Extendify\HelpCenter\Controllers; |
| 8 |
|
| 9 |
defined('ABSPATH') || die('No direct access.'); |
| 10 |
|
| 11 |
use Extendify\Shared\Services\Sanitizer; |
| 12 |
|
| 13 |
/** |
| 14 |
* The controller for plugin dependency checking, etc |
| 15 |
*/ |
| 16 |
|
| 17 |
class RouterController |
| 18 |
{ |
| 19 |
/** |
| 20 |
* Return the data |
| 21 |
* |
| 22 |
* @return \WP_REST_Response |
| 23 |
*/ |
| 24 |
public static function get() |
| 25 |
{ |
| 26 |
$data = get_option('extendify_help_center_router', []); |
| 27 |
return new \WP_REST_Response($data); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Persist the data |
| 32 |
* |
| 33 |
* @param \WP_REST_Request $request - The request. |
| 34 |
* @return \WP_REST_Response |
| 35 |
*/ |
| 36 |
public static function store($request) |
| 37 |
{ |
| 38 |
$data = $request->get_param('state'); |
| 39 |
update_option('extendify_help_center_router', [ |
| 40 |
'state' => Sanitizer::sanitizeArray($data), |
| 41 |
]); |
| 42 |
return new \WP_REST_Response($data); |
| 43 |
} |
| 44 |
} |
| 45 |
|