1 | <?php |
||
29 | class FlashPlugin extends Plugin |
||
30 | { |
||
31 | /** |
||
32 | * @var \Caridea\Session\Map A session value namespace for current vals |
||
33 | */ |
||
34 | protected $curr; |
||
35 | /** |
||
36 | * @var \Caridea\Session\Map A session value namespace for next vals |
||
37 | */ |
||
38 | protected $next; |
||
39 | /** |
||
40 | * @var bool whether the values have been moved |
||
41 | */ |
||
42 | protected $moved = false; |
||
43 | |||
44 | /** |
||
45 | * Creates a new FlashPlugin. |
||
46 | */ |
||
47 | 1 | public function __construct() |
|
52 | |||
53 | /** |
||
54 | * Removes any flash values for the _next_ request, optionally also in the _current_. |
||
55 | * |
||
56 | * @param bool $current If true, also clears flash values from the _current_ request. |
||
57 | */ |
||
58 | 1 | public function clear(bool $current = false): void |
|
65 | |||
66 | /** |
||
67 | * Gets the flash values for the _current_ request. |
||
68 | * |
||
69 | * @return \Iterator The current request flash values |
||
70 | */ |
||
71 | 1 | public function getAllCurrent(): \Iterator |
|
75 | |||
76 | /** |
||
77 | * Gets the flash values for the _next_ request. |
||
78 | * |
||
79 | * @return \Iterator The next request flash values |
||
80 | */ |
||
81 | 1 | public function getAllNext(): \Iterator |
|
85 | |||
86 | /** |
||
87 | * Gets the flash value for a key in the _current_ request. |
||
88 | * |
||
89 | * @param string $name The name |
||
90 | * @param mixed $alt Optional default value to return |
||
91 | * @return mixed The value, or the `$alt` if not found |
||
92 | */ |
||
93 | 2 | public function getCurrent(string $name, $alt = null) |
|
97 | /** |
||
98 | * |
||
99 | * Gets the flash value for a key in the *next* request. |
||
100 | * |
||
101 | * @param string $name The name |
||
102 | * @param mixed $alt Optional default value to return |
||
103 | * @return mixed The value, or the `$alt` if not found |
||
104 | */ |
||
105 | 2 | public function getNext(string $name, $alt = null) |
|
109 | |||
110 | /** |
||
111 | * Repeats any values in the current flash step in the next step. |
||
112 | */ |
||
113 | 1 | public function keep(): void |
|
117 | |||
118 | /** |
||
119 | * Sets a flash value for the _next_ request, optionally also in the _current_ request. |
||
120 | * |
||
121 | * @param string $name The name |
||
122 | * @param mixed $value The value |
||
123 | * @param bool $current If true, also sets flash value for the _current_ request. |
||
124 | */ |
||
125 | 2 | public function set(string $name, $value, bool $current = false): void |
|
132 | |||
133 | /** |
||
134 | * {@inheritDoc} |
||
135 | */ |
||
136 | 1 | public function onStart(Session $session): void |
|
142 | |||
143 | /** |
||
144 | * Transitions the values from next to current. |
||
145 | */ |
||
146 | 1 | protected function cycle() |
|
155 | } |
||
156 |