WC_REST_System_Status_Tools_Controller::update_item PHP Method

update_item() public method

Update (execute) a tool.
public update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request
return WP_Error | WP_REST_Response
    public function update_item($request)
    {
        $tools = $this->get_tools();
        if (empty($tools[$request['id']])) {
            return new WP_Error('woocommerce_rest_system_status_tool_invalid_id', __('Invalid tool ID.', 'woocommerce'), array('status' => 404));
        }
        $tool = $tools[$request['id']];
        $tool = array('id' => $request['id'], 'name' => $tool['name'], 'action' => $tool['button'], 'description' => $tool['desc']);
        $execute_return = $this->execute_tool($request['id']);
        $tool = array_merge($tool, $execute_return);
        $request->set_param('context', 'edit');
        $response = $this->prepare_item_for_response($tool, $request);
        return rest_ensure_response($response);
    }