36 lines
743 B
PHP
36 lines
743 B
PHP
|
<?php
|
||
|
|
||
|
namespace Aweos\Resizer\Jobs;
|
||
|
|
||
|
use Aweos\Resizer\Classes\CacheManager;
|
||
|
use Aweos\Resizer\Lib\MediaPath;
|
||
|
use Aweos\Resizer\Lib\TempMediaPath;
|
||
|
use Log;
|
||
|
use Throwable;
|
||
|
|
||
|
class ResizeJob
|
||
|
{
|
||
|
|
||
|
public function fire($job, $params)
|
||
|
{
|
||
|
list($file) = $params;
|
||
|
$media = new TempMediaPath($file);
|
||
|
app(ImageResizer::class)->generate($media, $params['update'] ?? false);
|
||
|
app(CacheManager::class)->delete($media);
|
||
|
unset ($media);
|
||
|
|
||
|
$job->delete();
|
||
|
}
|
||
|
|
||
|
public function failed($data, Throwable $e)
|
||
|
{
|
||
|
Log::error("Resizing of image failed", [
|
||
|
'message' => $e->getMessage(),
|
||
|
'exception' => $e,
|
||
|
'data' => $data,
|
||
|
]);
|
||
|
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|