bristol-su /
control
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | namespace BristolSU\ControlDB\Observers; |
||
| 4 | |||
| 5 | use BristolSU\ControlDB\Cache\Group as GroupCache; |
||
| 6 | use BristolSU\ControlDB\Contracts\Models\Group as GroupModel; |
||
| 7 | use Illuminate\Contracts\Cache\Repository; |
||
| 8 | |||
| 9 | class GroupObserverClearCache |
||
|
0 ignored issues
–
show
|
|||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
|
0 ignored issues
–
show
|
|||
| 13 | * @var Repository |
||
| 14 | */ |
||
| 15 | private $cache; |
||
|
0 ignored issues
–
show
|
|||
| 16 | |||
| 17 | 4 | public function __construct(Repository $cache) |
|
|
0 ignored issues
–
show
|
|||
| 18 | { |
||
| 19 | 4 | $this->cache = $cache; |
|
| 20 | 4 | } |
|
| 21 | |||
| 22 | 2 | public function create(GroupModel $groupModel) |
|
|
0 ignored issues
–
show
|
|||
| 23 | { |
||
| 24 | 2 | $this->cache->forget(GroupCache::class . '@count'); |
|
| 25 | 2 | $this->cache->forget(GroupCache::class . '@getByDataProviderId:' . $groupModel->dataProviderId()); |
|
| 26 | 2 | } |
|
| 27 | |||
| 28 | 1 | public function delete(GroupModel $group) |
|
|
0 ignored issues
–
show
|
|||
| 29 | { |
||
| 30 | 1 | $this->cache->forget(GroupCache::class . '@count'); |
|
| 31 | 1 | $this->cache->forget(GroupCache::class . '@getById:' . $group->id()); |
|
| 32 | 1 | $this->cache->forget(GroupCache::class . '@getByDataProviderId:' . $group->dataProviderId()); |
|
| 33 | 1 | } |
|
| 34 | |||
| 35 | 1 | public function update(GroupModel $oldGroup, GroupModel $newGroup) |
|
|
0 ignored issues
–
show
|
|||
| 36 | { |
||
| 37 | 1 | $this->cache->forget(GroupCache::class . '@count'); |
|
| 38 | 1 | $this->cache->forget(GroupCache::class . '@getById:' . $newGroup->id()); |
|
| 39 | 1 | $this->cache->forget(GroupCache::class . '@getByDataProviderId:' . $oldGroup->dataProviderId()); |
|
| 40 | 1 | $this->cache->forget(GroupCache::class . '@getByDataProviderId:' . $newGroup->dataProviderId()); |
|
| 41 | 1 | } |
|
| 42 | |||
| 43 | } |