WC_REST_Fulfillments_V4_Controller::get_authentication_error_by_methodprotectedWC 1.0

Returns an authentication error message for a given HTTP verb.

Method of the class: WC_REST_Fulfillments_V4_Controller{}

No Hooks.

Returns

Array|null. Error information on success, null otherwise.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_authentication_error_by_method( $method );
$method(string) (required)
HTTP method.

WC_REST_Fulfillments_V4_Controller::get_authentication_error_by_method() code WC 10.3.6

protected function get_authentication_error_by_method( string $method ) {
	$errors = array(
		'GET'    => array(
			'code'    => 'woocommerce_rest_cannot_view',
			'message' => __( 'Sorry, you cannot view resources.', 'woocommerce' ),
		),
		'POST'   => array(
			'code'    => 'woocommerce_rest_cannot_create',
			'message' => __( 'Sorry, you cannot create resources.', 'woocommerce' ),
		),
		'PUT'    => array(
			'code'    => 'woocommerce_rest_cannot_update',
			'message' => __( 'Sorry, you cannot update resources.', 'woocommerce' ),
		),
		'PATCH'  => array(
			'code'    => 'woocommerce_rest_cannot_update',
			'message' => __( 'Sorry, you cannot update resources.', 'woocommerce' ),
		),
		'DELETE' => array(
			'code'    => 'woocommerce_rest_cannot_delete',
			'message' => __( 'Sorry, you cannot delete resources.', 'woocommerce' ),
		),
	);

	return $errors[ $method ] ?? null;
}