oc-resizer-plugin/jobs/ResizeJob.php

37 lines
783 B
PHP
Raw Normal View History

2022-02-16 02:49:19 +01:00
<?php
namespace Aweos\Resizer\Jobs;
use Aweos\Resizer\Classes\CacheManager;
2022-02-16 03:15:07 +01:00
use Aweos\Resizer\Classes\ImageResizer;
2022-02-16 02:49:19 +01:00
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;
}
}