refactoring the session payload.
This commit is contained in:
parent
82b75166ac
commit
06bf0a40a6
|
@ -236,20 +236,11 @@ protected function age()
|
||||||
if (strpos($key, ':old:') === 0) $this->forget($key);
|
if (strpos($key, ':old:') === 0) $this->forget($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->replace(':new:', ':old:', array_keys($this->session['data']));
|
// Now that all of the "old" keys have been removed from the session data,
|
||||||
}
|
// we can re-address all of the newly flashed keys to have old addresses.
|
||||||
|
// The array_combine method uses the first array for keys, and the second
|
||||||
/**
|
// array for values to construct a single array from both.
|
||||||
* Re-address the session data by performing a string replacement on the keys.
|
$keys = str_replace(':new', ':old:', array_keys($this->session['data']));
|
||||||
*
|
|
||||||
* @param string $search
|
|
||||||
* @param string $replace
|
|
||||||
* @param array $keys
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function replace($search, $replace, $keys)
|
|
||||||
{
|
|
||||||
$keys = str_replace($search, $replace, $keys);
|
|
||||||
|
|
||||||
$this->session['data'] = array_combine($keys, array_values($this->session['data']));
|
$this->session['data'] = array_combine($keys, array_values($this->session['data']));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue