mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Create object able to clear database.
This commit is contained in:
parent
374ce5d5f9
commit
f0798d7e88
2 changed files with 66 additions and 0 deletions
34
modules/ppcp-uninstall/src/ClearDatabase.php
Normal file
34
modules/ppcp-uninstall/src/ClearDatabase.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Clears the plugin related data from DB.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\Uninstall
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\Uninstall;
|
||||
|
||||
/**
|
||||
* Class ClearDatabase
|
||||
*/
|
||||
class ClearDatabase implements ClearDatabaseInterface {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function delete_options( array $option_names ):void {
|
||||
foreach ( $option_names as $option_name ) {
|
||||
delete_option( $option_name );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function clear_scheduled_actions( array $action_names ):void {
|
||||
foreach ( $action_names as $action_name ) {
|
||||
as_unschedule_action( $action_name );
|
||||
}
|
||||
}
|
||||
}
|
32
modules/ppcp-uninstall/src/ClearDatabaseInterface.php
Normal file
32
modules/ppcp-uninstall/src/ClearDatabaseInterface.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Can delete the options and clear scheduled actions from database.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\Uninstall
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\Uninstall;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
interface ClearDatabaseInterface {
|
||||
|
||||
/**
|
||||
* Deletes the given options from database.
|
||||
*
|
||||
* @param string[] $option_names The list of option names.
|
||||
* @throws RuntimeException If problem deleting.
|
||||
*/
|
||||
public function delete_options( array $option_names ): void;
|
||||
|
||||
/**
|
||||
* Clears the given scheduled actions.
|
||||
*
|
||||
* @param string[] $action_names The list of scheduled action names.
|
||||
* @throws RuntimeException If problem clearing.
|
||||
*/
|
||||
public function clear_scheduled_actions( array $action_names ): void;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue