Yoast\WP\SEO\MyYoast_Client\Infrastructure\Token
User_Token_Storage::store
Stores a token set for a user (encrypted). The resource bucket is derived from the token's own resource indicator.
Метод класса: User_Token_Storage{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$User_Token_Storage = new User_Token_Storage(); $User_Token_Storage->store( $user_id, $token_set ): void;
- $user_id(int) (обязательный)
- The user ID.
- $token_set(Token_Set) (обязательный)
- The token set to store.
Код User_Token_Storage::store() User Token Storage::store Yoast 28.3
public function store( int $user_id, 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 );
}
$this->user_helper->update_meta( $user_id, $this->get_meta_key( $token_set->get_resource_indicator() ), $encrypted );
}