Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/FlashSegmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions tests/InterfaceContractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 {}
Expand Down
Loading