diff --git a/CHANGELOG.md b/CHANGELOG.md index 560bdfd..6af4d19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # CHANGELOG -## 7.0.0 +## 7.0.0-beta2 + +- (ADD) `Aura\Session_Interface\FlashSegmentInterface` gains `getFlashAll()` and `getFlashNextAll()`, which return every flash value for the current or the next request, so consumers can render flash messages without knowing the keys. Neither takes an alternative value, and both return an empty array when nothing is set. +- (BRK) Implementations written against `7.0.0-beta1` must add those two methods. + +## 7.0.0-beta1 Initial release. diff --git a/README.md b/README.md index 3aac1a0..2597b29 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,13 @@ The contract for managing a segment as a whole: ### `Aura\Session_Interface\FlashSegmentInterface` The contract for "flash" values (available for the next request, and/or the -current one): `setFlash()`, `getFlash()`, `clearFlash()`, `getFlashNext()`, -`setFlashNow()`, `clearFlashNow()`, and `keepFlash()`. +current one): `setFlash()`, `getFlash()`, `getFlashAll()`, `clearFlash()`, +`getFlashNext()`, `getFlashNextAll()`, `setFlashNow()`, `clearFlashNow()`, and +`keepFlash()`. + +The two all-getters return every flash value for the current or the next +request, so a consumer can render them without knowing the keys in advance; +both return an empty array when there is nothing set. Each of these is a separate interface so that consumers that only read and write plain values do not have to depend on whole-segment management or flash diff --git a/src/FlashSegmentInterface.php b/src/FlashSegmentInterface.php index 6739bdf..7d62570 100644 --- a/src/FlashSegmentInterface.php +++ b/src/FlashSegmentInterface.php @@ -46,6 +46,16 @@ public function setFlash(string $key, mixed $val): void; */ public function getFlash(string $key, mixed $alt = null): mixed; + /** + * + * Gets all the flash values for the *current* request. + * + * @return array All the flash values for the current request; empty when + * there are none. + * + */ + public function getFlashAll(): array; + /** * * Clears flash values for *only* the next request. @@ -68,6 +78,16 @@ public function clearFlash(): void; */ public function getFlashNext(string $key, mixed $alt = null): mixed; + /** + * + * Gets all the flash values for the *next* request. + * + * @return array All the flash values for the next request; empty when + * there are none. + * + */ + public function getFlashNextAll(): array; + /** * * Sets a flash value for the *next* request *and* the current one. diff --git a/tests/InterfaceContractTest.php b/tests/InterfaceContractTest.php index c28ce20..96b1c8c 100644 --- a/tests/InterfaceContractTest.php +++ b/tests/InterfaceContractTest.php @@ -42,8 +42,10 @@ class InterfaceContractTest extends TestCase FlashSegmentInterface::class => [ 'setFlash' => 'void', 'getFlash' => 'mixed', + 'getFlashAll' => 'array', 'clearFlash' => 'void', 'getFlashNext' => 'mixed', + 'getFlashNextAll' => 'array', 'setFlashNow' => 'void', 'clearFlashNow' => 'void', 'keepFlash' => 'void', @@ -114,8 +116,10 @@ public function clear(): void { $this->data = []; } public function remove(?string $key = null): void { $key === null ? $this->data = [] : $this->data[$key] = null; } public function setFlash(string $key, mixed $val): void {} public function getFlash(string $key, mixed $alt = null): mixed { return $alt; } + public function getFlashAll(): array { return []; } public function clearFlash(): void {} public function getFlashNext(string $key, mixed $alt = null): mixed { return $alt; } + public function getFlashNextAll(): array { return []; } public function setFlashNow(string $key, mixed $val): void {} public function clearFlashNow(): void {} public function keepFlash(): void {}