|
1
|
|
|
<?php |
|
2
|
|
|
|
|
|
|
|
|
|
3
|
|
|
namespace BristolSU\ControlDB\Observers; |
|
4
|
|
|
|
|
5
|
|
|
use BristolSU\ControlDB\Cache\Role as RoleCache; |
|
6
|
|
|
use BristolSU\ControlDB\Contracts\Models\Role as RoleModel; |
|
7
|
|
|
use Illuminate\Contracts\Cache\Repository; |
|
8
|
|
|
|
|
9
|
|
|
class RoleObserverClearCache |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
|
|
|
|
|
13
|
|
|
* @var Repository |
|
14
|
|
|
*/ |
|
15
|
|
|
private $cache; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
8 |
|
public function __construct(Repository $cache) |
|
|
|
|
|
|
18
|
|
|
{ |
|
19
|
8 |
|
$this->cache = $cache; |
|
20
|
8 |
|
} |
|
21
|
|
|
|
|
22
|
2 |
|
public function create(RoleModel $roleModel) |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
2 |
|
$this->cache->forget(RoleCache::class . '@count'); |
|
25
|
2 |
|
$this->cache->forget(RoleCache::class . '@getByDataProviderId:' . $roleModel->dataProviderId()); |
|
26
|
2 |
|
$this->cache->forget(RoleCache::class . '@allThroughGroup:' . $roleModel->groupId()); |
|
27
|
2 |
|
$this->cache->forget(RoleCache::class . '@allThroughPosition:' . $roleModel->positionId()); |
|
28
|
2 |
|
} |
|
29
|
|
|
|
|
30
|
1 |
|
public function delete(RoleModel $role) |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
1 |
|
$this->cache->forget(RoleCache::class . '@count'); |
|
33
|
1 |
|
$this->cache->forget(RoleCache::class . '@getById:' . $role->id()); |
|
34
|
1 |
|
$this->cache->forget(RoleCache::class . '@getByDataProviderId:' . $role->dataProviderId()); |
|
35
|
1 |
|
$this->cache->forget(RoleCache::class . '@allThroughGroup:' . $role->groupId()); |
|
36
|
1 |
|
$this->cache->forget(RoleCache::class . '@allThroughPosition:' . $role->positionId()); |
|
37
|
1 |
|
} |
|
38
|
|
|
|
|
39
|
5 |
|
public function update(RoleModel $oldRole, RoleModel $newRole) |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
5 |
|
$this->cache->forget(RoleCache::class . '@count'); |
|
42
|
5 |
|
$this->cache->forget(RoleCache::class . '@getById:' . $newRole->id()); |
|
43
|
5 |
|
$this->cache->forget(RoleCache::class . '@getByDataProviderId:' . $oldRole->dataProviderId()); |
|
44
|
5 |
|
$this->cache->forget(RoleCache::class . '@getByDataProviderId:' . $newRole->dataProviderId()); |
|
45
|
5 |
|
$this->cache->forget(RoleCache::class . '@allThroughPosition:' . $oldRole->positionId()); |
|
46
|
5 |
|
$this->cache->forget(RoleCache::class . '@allThroughPosition:' . $newRole->positionId()); |
|
47
|
5 |
|
$this->cache->forget(RoleCache::class . '@allThroughGroup:' . $oldRole->groupId()); |
|
48
|
5 |
|
$this->cache->forget(RoleCache::class . '@allThroughGroup:' . $newRole->groupId()); |
|
49
|
5 |
|
} |
|
50
|
|
|
|
|
51
|
|
|
} |