Yoast\WP\SEO\MyYoast_Client\Infrastructure\Token
Token_Storage::store
Stores a token set (encrypted). The resource bucket is derived from the token's own resource indicator.
Метод класса: Token_Storage{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Token_Storage = new Token_Storage(); $Token_Storage->store( $token_set ): void;
- $token_set(Token_Set) (обязательный)
- The token set to store.
Код Token_Storage::store() Token Storage::store Yoast 28.3
public function store( Token_Set $token_set ): void {
try {
// phpcs:ignore Yoast.Yoast.JsonEncodeAlternative.Found -- Encoding for encrypted storage, not user-facing output.
$json = \wp_json_encode( $token_set->to_array() );
if ( $json === false ) {
throw new Token_Storage_Exception( 'Failed to JSON-encode token set for storage.' );
}
$encrypted = $this->encryption->encrypt( $json, self::ENCRYPTION_CONTEXT );
}
catch ( Encryption_Exception $e ) {
// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Internal exception message.
throw new Token_Storage_Exception( 'Failed to encrypt token set for storage: ' . $e->getMessage(), 0, $e );
}
\update_option( $this->get_option_key( $token_set->get_resource_indicator() ), $encrypted, false );
}