openvk/Web/Models/Entities/VideoAlbum.php
Alexander Minkin 6ec54a379d
feat: add linting of code (#1220)
* feat(lint): add php-cs-fixer for linting

Removing previous CODE_STYLE as it was not enforced anyway and using PER-CS 2.0.

This is not the reformatting commit.

* style: format code according to PER-CS 2.0 with php-cs-fixer

* ci(actions): add lint action

Resolves #1132.
2025-01-31 18:20:13 +03:00

49 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace openvk\Web\Models\Entities;
use openvk\Web\Models\Repositories\Videos;
class VideoAlbum extends MediaCollection
{
public const SPECIAL_ADDED = 16;
public const SPECIAL_UPLOADED = 32;
protected $tableName = "video_playlists";
protected $relTableName = "vp_relations";
protected $entityTableName = "videos";
protected $entityClassName = 'openvk\Web\Models\Entities\Video';
protected $specialNames = [
16 => "_added_album",
32 => "_uploaded_album",
];
public function getCoverURL(): ?string
{
$cover = $this->getCoverVideo();
if (!$cover) {
return "/assets/packages/static/openvk/img/camera_200.png";
}
return $cover->getThumbnailURL();
}
public function getCoverVideo(): ?Photo
{
$cover = $this->getRecord()->cover_video;
if (!$cover) {
$vids = iterator_to_array($this->fetch(1, 1));
$vid = $vids[0] ?? null;
if (!$vid || $vid->isDeleted()) {
return null;
} else {
return $vid;
}
}
return (new Videos())->get($cover);
}
}