39 lines
824 B
PHP
39 lines
824 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 MoveJob
|
||
|
{
|
||
|
|
||
|
public function fire($job, $params)
|
||
|
{
|
||
|
list($old, $new) = $params;
|
||
|
$old = new StorageMediaPath($old);
|
||
|
$new = new StorageMediaPath($new);
|
||
|
app(FileObserver::class)->rename($old, $new);
|
||
|
app(CacheManager::class)->delete($old);
|
||
|
unset ($old);
|
||
|
unset ($new);
|
||
|
|
||
|
$job->delete();
|
||
|
}
|
||
|
|
||
|
public function failed($data, Throwable $e)
|
||
|
{
|
||
|
Log::error("Deleting of image failed", [
|
||
|
'message' => $e->getMessage(),
|
||
|
'exception' => $e,
|
||
|
'data' => $data,
|
||
|
]);
|
||
|
|
||
|
throw $e;
|
||
|
}
|
||
|
}
|