<?php
namespace App\Entity\Channel;
use App\Entity\ChannelUserData\AdminChannelUserData;
use App\Entity\Sync\SyncableInterface;
use App\Repository\Channel\ChannelUserSessionPermissionRepository;
use Doctrine\ORM\Mapping as ORM;
use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelUserData\AdminChannelUserDataInterface;
use Nellapp\Bundle\SDKBundle\Permission\Entity\AbstractChannelUserResourcePermission;
use Nellapp\Bundle\SDKBundle\Permission\Entity\ChannelResourceInterface;
use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
use Symfony\Component\Serializer\Annotation as Serial;
#[
ORM\Entity(repositoryClass: ChannelUserSessionPermissionRepository::class),
ORM\Table('channel_user_session_permissions'),
]
class ChannelUserSessionPermission extends AbstractChannelUserResourcePermission implements SyncableInterface
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
#[Serial\Groups(['Sync'])]
protected ?int $id = null;
#[ORM\ManyToOne(targetEntity: AdminChannelUserData::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[IdGroups(['Sync'])]
protected ?AdminChannelUserDataInterface $channelUserData = null;
#[ORM\ManyToOne(targetEntity: Session::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[IdGroups(['Sync'])]
protected ?ChannelResourceInterface $resource = null;
public static function getSyncKey(): string
{
return EntityKeys::CHANNEL_USER_PERM_SESSION;
}
public function getSyncDisplayLabel(): string
{
return $this->getResource() . ' - ' . $this->getChannelUserData()?->getUser();
}
}