- Fully transitioned the backend to the Porto architectural pattern - Improved code organization and maintainability - Fixed minor bugs and inconsistencies
57 lines
1.0 KiB
PHP
57 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Observers;
|
|
|
|
use App\Containers\Article\Models\Tag;
|
|
use App\Services\App\Cache\TagCacheService;
|
|
|
|
class TagObserver
|
|
{
|
|
protected TagCacheService $tagCacheService;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->tagCacheService = new TagCacheService();
|
|
}
|
|
|
|
/**
|
|
* Handle the Post "created" event.
|
|
*/
|
|
public function saved(Tag $tag): void
|
|
{
|
|
$this->tagCacheService->clearAllCacheByModel();
|
|
}
|
|
|
|
/**
|
|
* Handle the Post "updated" event.
|
|
*/
|
|
public function updated(Tag $tag)
|
|
{
|
|
$this->tagCacheService->clearAllCacheByModel();
|
|
}
|
|
|
|
/**
|
|
* Очистка кеша при удалении поста.
|
|
*/
|
|
public function deleted(Tag $tag)
|
|
{
|
|
$this->tagCacheService->clearAllCacheByModel();
|
|
}
|
|
|
|
/**
|
|
* Handle the Post "restored" event.
|
|
*/
|
|
public function restored(Tag $tag): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Handle the Post "force deleted" event.
|
|
*/
|
|
public function forceDeleted(Tag $tag): void
|
|
{
|
|
//
|
|
}
|
|
}
|