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\Position as PositionCache; |
||
| 6 | use BristolSU\ControlDB\Contracts\Models\Position as PositionModel; |
||
| 7 | use Illuminate\Contracts\Cache\Repository; |
||
| 8 | |||
| 9 | class PositionObserverClearCache |
||
|
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(PositionModel $positionModel) |
|
|
0 ignored issues
–
show
|
|||
| 23 | { |
||
| 24 | 2 | $this->cache->forget(PositionCache::class . '@count'); |
|
| 25 | 2 | $this->cache->forget(PositionCache::class . '@getByDataProviderId:' . $positionModel->dataProviderId()); |
|
| 26 | 2 | } |
|
| 27 | |||
| 28 | 1 | public function delete(PositionModel $position) |
|
|
0 ignored issues
–
show
|
|||
| 29 | { |
||
| 30 | 1 | $this->cache->forget(PositionCache::class . '@count'); |
|
| 31 | 1 | $this->cache->forget(PositionCache::class . '@getById:' . $position->id()); |
|
| 32 | 1 | $this->cache->forget(PositionCache::class . '@getByDataProviderId:' . $position->dataProviderId()); |
|
| 33 | 1 | } |
|
| 34 | |||
| 35 | 1 | public function update(PositionModel $oldPosition, PositionModel $newPosition) |
|
|
0 ignored issues
–
show
|
|||
| 36 | { |
||
| 37 | 1 | $this->cache->forget(PositionCache::class . '@count'); |
|
| 38 | 1 | $this->cache->forget(PositionCache::class . '@getById:' . $newPosition->id()); |
|
| 39 | 1 | $this->cache->forget(PositionCache::class . '@getByDataProviderId:' . $oldPosition->dataProviderId()); |
|
| 40 | 1 | $this->cache->forget(PositionCache::class . '@getByDataProviderId:' . $newPosition->dataProviderId()); |
|
| 41 | 1 | } |
|
| 42 | |||
| 43 | } |