oc-resizer-plugin/jobs/DeleteJob.php

37 lines
759 B
PHP
Raw Permalink Normal View History

2022-02-16 02:49:19 +01:00
<?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;
}
}