← All changes
|
src/myyoast-client/application/ports/user-token-storage-interface.php
+33
-8
27.8
→
trunk
View file →
| @@ -3,26 +3,31 @@ | ||
| 3 | 3 | |
| 4 | 4 | namespace Yoast\WP\SEO\MyYoast_Client\Application\Ports; |
| 5 | 5 | |
| 6 | 6 | use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Token_Storage_Exception; |
| 7 | +use Yoast\WP\SEO\MyYoast_Client\Domain\Resource_Indicator; | |
| 7 | 8 | use Yoast\WP\SEO\MyYoast_Client\Domain\Token_Set; |
| 8 | 9 | |
| 9 | 10 | /** |
| 10 | 11 | * Port for per-user token persistence. |
| 12 | + * | |
| 13 | + * Tokens are bucketed by RFC 8707 resource indicator so a user can hold one | |
| 14 | + * token per resource server. The null bucket is the default resource. | |
| 11 | 15 | */ |
| 12 | 16 | interface User_Token_Storage_Interface { |
| 13 | 17 | |
| 14 | 18 | /** |
| 15 | - * Retrieves the stored token set for a user. | |
| 19 | + * Retrieves the stored token set for a user and resource bucket. | |
| 16 | 20 | * |
| 17 | - * @param int $user_id The user ID. | |
| 21 | + * @param int $user_id The user ID. | |
| 22 | + * @param Resource_Indicator $resource_indicator The resource indicator (use Resource_Indicator::default() for the default bucket). | |
| 18 | 23 | * |
| 19 | 24 | * @return Token_Set|null The token set, or null if not stored. |
| 20 | 25 | */ |
| 21 | - public function get( int $user_id ): ?Token_Set; | |
| 26 | + public function get( int $user_id, Resource_Indicator $resource_indicator ): ?Token_Set; | |
| 22 | 27 | |
| 23 | 28 | /** |
| 24 | - * Stores a token set for a user. | |
| 29 | + * Stores a token set for a user. The resource bucket is derived from the token's own resource indicator. | |
| 25 | 30 | * |
| 26 | 31 | * @param int $user_id The user ID. |
| 27 | 32 | * @param Token_Set $token_set The token set to store. |
| 28 | 33 | * |
| @@ -32,19 +37,39 @@ | ||
| 32 | 37 | */ |
| 33 | 38 | public function store( int $user_id, Token_Set $token_set ): void; |
| 34 | 39 | |
| 35 | 40 | /** |
| 36 | - * Deletes the stored token set for a user. | |
| 41 | + * Deletes the stored token set for a user and resource bucket. | |
| 37 | 42 | * |
| 43 | + * @param int $user_id The user ID. | |
| 44 | + * @param Resource_Indicator $resource_indicator The resource indicator (use Resource_Indicator::default() for the default bucket). | |
| 45 | + * | |
| 46 | + * @return void | |
| 47 | + */ | |
| 48 | + public function delete( int $user_id, Resource_Indicator $resource_indicator ): void; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * Returns every stored token set across resource buckets for a user. | |
| 52 | + * | |
| 38 | 53 | * @param int $user_id The user ID. |
| 39 | 54 | * |
| 55 | + * @return Token_Set[] The stored token sets. | |
| 56 | + */ | |
| 57 | + public function get_all( int $user_id ): array; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Deletes every stored user token set across all users and resource buckets for the current issuer. | |
| 61 | + * | |
| 40 | 62 | * @return void |
| 41 | 63 | */ |
| 42 | - public function delete( int $user_id ): void; | |
| 64 | + public function delete_all(): void; | |
| 43 | 65 | |
| 44 | 66 | /** |
| 45 | - * Deletes all stored user token sets. | |
| 67 | + * Deletes every stored user token set across all users, issuers, and resource buckets. | |
| 46 | 68 | * |
| 69 | + * Intended for full plugin cleanup on uninstall, where any token bucket | |
| 70 | + * for any issuer that this site ever connected to should be purged. | |
| 71 | + * | |
| 47 | 72 | * @return void |
| 48 | 73 | */ |
| 49 | - public function delete_all(): void; | |
| 74 | + public function delete_all_issuers(): void; | |
| 50 | 75 | } |