mirror of
https://github.com/openvk/openvk
synced 2025-02-02 21:15:42 +03:00
Alexander Minkin
6ec54a379d
* 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.
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace openvk\Web\Models\Entities\Traits;
|
|
|
|
use openvk\Web\Models\Entities\Photo;
|
|
use openvk\Web\Models\Repositories\Photos;
|
|
|
|
trait TBackDrops
|
|
{
|
|
public function getBackDropPictureURLs(): ?array
|
|
{
|
|
$photo1 = $this->getRecord()->backdrop_1;
|
|
$photo2 = $this->getRecord()->backdrop_2;
|
|
if (is_null($photo1) && is_null($photo2)) {
|
|
return null;
|
|
}
|
|
|
|
$photo1obj = $photo2obj = null;
|
|
if (!is_null($photo1)) {
|
|
$photo1obj = (new Photos())->get($photo1);
|
|
}
|
|
if (!is_null($photo2)) {
|
|
$photo2obj = (new Photos())->get($photo2);
|
|
}
|
|
|
|
if (is_null($photo1obj) && is_null($photo2obj)) {
|
|
return null;
|
|
}
|
|
|
|
return [
|
|
is_null($photo1obj) ? "" : $photo1obj->getURL(),
|
|
is_null($photo2obj) ? "" : $photo2obj->getURL(),
|
|
];
|
|
}
|
|
|
|
public function setBackDropPictures(?Photo $first, ?Photo $second): void
|
|
{
|
|
if (!is_null($first)) {
|
|
$this->stateChanges("backdrop_1", $first->getId());
|
|
}
|
|
|
|
if (!is_null($second)) {
|
|
$this->stateChanges("backdrop_2", $second->getId());
|
|
}
|
|
}
|
|
|
|
public function unsetBackDropPictures(): void
|
|
{
|
|
$this->stateChanges("backdrop_1", null);
|
|
$this->stateChanges("backdrop_2", null);
|
|
}
|
|
}
|