create-prisma-php-app 1.10.3 → 1.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -96,7 +96,8 @@ class StateManager
|
|
|
96
96
|
/**
|
|
97
97
|
* Resets the application state partially or completely.
|
|
98
98
|
*
|
|
99
|
-
* @param string|null $key The key of the state to reset. If null, resets the entire state.
|
|
99
|
+
* @param string|array|null $key The key(s) of the state to reset. If null, resets the entire state.
|
|
100
|
+
* Can be a string for a single key or an array of strings for multiple keys.
|
|
100
101
|
* @param bool $clearFromStorage Whether to clear the state from storage.
|
|
101
102
|
*/
|
|
102
103
|
public function resetState($key = null, $clearFromStorage = false)
|
|
@@ -104,8 +105,13 @@ class StateManager
|
|
|
104
105
|
if ($key === null) {
|
|
105
106
|
// Reset the entire state
|
|
106
107
|
$this->state = [];
|
|
108
|
+
} elseif (is_array($key)) {
|
|
109
|
+
// Reset only the parts of the state identified by the keys in the array
|
|
110
|
+
foreach ($key as $k) {
|
|
111
|
+
unset($this->state[$k]);
|
|
112
|
+
}
|
|
107
113
|
} else {
|
|
108
|
-
// Reset only the part of the state identified by
|
|
114
|
+
// Reset only the part of the state identified by a single key
|
|
109
115
|
unset($this->state[$key]);
|
|
110
116
|
}
|
|
111
117
|
|
|
@@ -117,9 +123,9 @@ class StateManager
|
|
|
117
123
|
if ($clearFromStorage) {
|
|
118
124
|
// Save the updated state to the session or clear it
|
|
119
125
|
if (empty($this->state)) {
|
|
120
|
-
unset($_SESSION[
|
|
126
|
+
unset($_SESSION['appState']);
|
|
121
127
|
} else {
|
|
122
|
-
$_SESSION[
|
|
128
|
+
$_SESSION['appState'] = json_encode($this->state);
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
131
|
}
|