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