-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathSaveSession.php
More file actions
61 lines (52 loc) · 1.32 KB
/
SaveSession.php
File metadata and controls
61 lines (52 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace ProcessMaker\Filters;
use Illuminate\Support\Facades\Cache;
class SaveSession
{
/**
* Retrieve cached data; this is preserved for a week.
* @param array $json
* @return array
*/
private static function get($key, $json)
{
return Cache::remember($key, now()->addWeek(), function () use ($json) {
return $json;
});
}
/**
* Get key cache remember
* @param User $user
* @param string $name
* @return string
*/
private static function getKey($user, $name)
{
return str_replace('-', '_', "user-{$user->id}-{$user->uuid}-{$name}");
}
/**
* Get filter configuration.
* @param string $name
* @param User $user
* @return type
*/
public static function getConfigFilter(String $name, Object $user)
{
$key = self::getKey($user, $name);
$default = ['filters' => []];
return self::get($key, $default);
}
/**
* Store filter configuration.
* @param string $name
* @param User $user
* @param array $array
* @return type
*/
public static function setConfigFilter(String $name, Object $user, array $array)
{
$key = self::getKey($user, $name);
Cache::pull($key);
return self::get($key, $array);
}
}