forked from GNUsocial/gnu-social
[Poll] Move tables from core to plugin
This commit is contained in:
parent
c8915df31e
commit
45a894c953
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Core\Cache;
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\Entity;
|
use App\Core\Entity;
|
||||||
use App\Core\Event;
|
use App\Core\Event;
|
||||||
@ -118,7 +119,10 @@ class AttachmentThumbnail extends Entity
|
|||||||
public static function getOrCreate(Attachment $attachment, ?int $width = null, ?int $height = null, ?bool $crop = null)
|
public static function getOrCreate(Attachment $attachment, ?int $width = null, ?int $height = null, ?bool $crop = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return DB::findOneBy('attachment_thumbnail', ['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height]);
|
return Cache::get('thumb-' . $attachment->getId() . "-{$width}x{$height}",
|
||||||
|
function () use ($attachment, $width, $height) {
|
||||||
|
return DB::findOneBy('attachment_thumbnail', ['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height]);
|
||||||
|
});
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
$thumbnail = self::create(['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height, 'attachment' => $attachment]);
|
$thumbnail = self::create(['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height, 'attachment' => $attachment]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user