37 lines
759 B
PHP
37 lines
759 B
PHP
|
<?php
|
||
|
|
||
|
namespace Aweos\Resizer\Jobs;
|
||
|
|
||
|
use Aweos\Resizer\Classes\CacheManager;
|
||
|
use Aweos\Resizer\Classes\FileObserver;
|
||
|
use Aweos\Resizer\Lib\MediaPath;
|
||
|
use Aweos\Resizer\Lib\StorageMediaPath;
|
||
|
use Log;
|
||
|
use Throwable;
|
||
|
|
||
|
class DeleteJob
|
||
|
{
|
||
|
|
||
|
public function fire($job, $params)
|
||
|
{
|
||
|
list($file) = $params;
|
||
|
$media = new StorageMediaPath($file);
|
||
|
app(FileObserver::class)->delete($media);
|
||
|
app(CacheManager::class)->delete($media);
|
||
|
unset ($media);
|
||
|
|
||
|
$job->delete();
|
||
|
}
|
||
|
|
||
|
public function failed($data, Throwable $e)
|
||
|
{
|
||
|
Log::error("Deleting of image failed", [
|
||
|
'message' => $e->getMessage(),
|
||
|
'exception' => $e,
|
||
|
'data' => $data,
|
||
|
]);
|
||
|
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|