Yoast\WP\SEO\MyYoast_Client\Application

MyYoast_Client_Cleanup{}Yoast 1.0└─ LoggerAwareInterface

Application service for cleaning up all MyYoast client data.

Orchestrates deregistration, token deletion, and local data cleanup. Used by the uninstall integration to cleanly remove all plugin state.

Хуков нет.

Использование

$MyYoast_Client_Cleanup = new MyYoast_Client_Cleanup();
// use class methods

Методы

  1. public __construct(
  2. public execute()

Код MyYoast_Client_Cleanup{} Yoast 27.7

class MyYoast_Client_Cleanup implements LoggerAwareInterface {
	use LoggerAwareTrait;

	/**
	 * The client registration port.
	 *
	 * @var Client_Registration_Interface
	 */
	private $client_registration;

	/**
	 * The site-level token storage port.
	 *
	 * @var Token_Storage_Interface
	 */
	private $token_storage;

	/**
	 * The user-level token storage port.
	 *
	 * @var User_Token_Storage_Interface
	 */
	private $user_token_storage;

	/**
	 * MyYoast_Client_Cleanup constructor.
	 *
	 * @param Client_Registration_Interface $client_registration The client registration port.
	 * @param Token_Storage_Interface       $token_storage       The site-level token storage port.
	 * @param User_Token_Storage_Interface  $user_token_storage  The user-level token storage port.
	 */
	public function __construct(
		Client_Registration_Interface $client_registration,
		Token_Storage_Interface $token_storage,
		User_Token_Storage_Interface $user_token_storage
	) {
		$this->client_registration = $client_registration;
		$this->token_storage       = $token_storage;
		$this->user_token_storage  = $user_token_storage;
		$this->logger              = new NullLogger();
	}

	/**
	 * Executes the full cleanup: deregister, delete tokens, delete local data.
	 *
	 * @return void
	 */
	public function execute(): void {
		// Best-effort server-side deregistration.
		try {
			$this->client_registration->deregister();
		}
		catch ( Exception $e ) {
			$this->logger->warning( 'MyYoast client deregistration failed during cleanup: {error}', [ 'error' => $e->getMessage() ] );
		}

		$this->user_token_storage->delete_all();
		$this->token_storage->delete();
		$this->client_registration->delete_local_data();
	}
}