Add docblock in controller class.

This commit is contained in:
Akeda Bagus 2019-07-09 15:55:40 +07:00
parent a41b66c602
commit 0f2e22de9a
No known key found for this signature in database
GPG Key ID: B21A9FC4B7761412
1 changed files with 28 additions and 0 deletions

View File

@ -57,6 +57,13 @@ class WC_REST_WCCOM_Site_Installer_Controller extends WC_REST_Controller {
);
}
/**
* Check permissions.
*
* @param WP_REST_Request $request Full details about the request.
*
* @return bool|WP_Error
*/
public function check_permission( $request ) {
if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'install_themes' ) ) {
return new WP_Error( 'woocommerce_rest_cannot_install_product', __( 'You do not have permission to install plugin or theme', 'woocommerce' ), array( 'status' => 401 ) );
@ -65,11 +72,25 @@ class WC_REST_WCCOM_Site_Installer_Controller extends WC_REST_Controller {
return true;
}
/**
* Get installation state.
*
* @param WP_REST_Request $request Full details about the request.
*
* @return bool|WP_Error
*/
public function get_install_state( $request ) {
require_once( WC_ABSPATH . 'includes/admin/helper/class-wc-helper.php' );
return rest_ensure_response( WC_Helper_Product_Install::get_state() );
}
/**
* Install WooCommerce.com products.
*
* @param WP_REST_Request $request Full details about the request.
*
* @return bool|WP_Error
*/
public function install( $request ) {
require_once( WC_ABSPATH . 'includes/admin/helper/class-wc-helper.php' );
@ -86,6 +107,13 @@ class WC_REST_WCCOM_Site_Installer_Controller extends WC_REST_Controller {
return rest_ensure_response( WC_Helper_Product_Install::install( $data['products'] ) );
}
/**
* Reset installation state.
*
* @param WP_REST_Request $request Full details about the request.
*
* @return bool|WP_Error
*/
public function reset_install( $request ) {
require_once( WC_ABSPATH . 'includes/admin/helper/class-wc-helper.php' );
$resp = rest_ensure_response( WC_Helper_Product_Install::reset_state() );