<?php
namespace App\Entity\Developers;
use App\Entity\Sync\SyncableInterface;
use Doctrine\ORM\Mapping as ORM;
use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiToken\ApiTokenInterface;
use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiTokenChannelAccess\ApiTokenChannelAccessInterface;
use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiTokenChannelAccess\ApiTokenChannelAccessMethodTrait;
use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
use Symfony\Component\Serializer\Annotation as Serial;
#[ORM\Entity]
#[ORM\UniqueConstraint(columns: ['token_id', 'channel_id'])]
#[ORM\Table(name: 'developers_api_token_channel_access')]
class ApiTokenChannelAccess implements ApiTokenChannelAccessInterface, SyncableInterface
{
use ApiTokenChannelAccessMethodTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Serial\Groups(['Sync'])]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: ApiTokenInterface::class, inversedBy: 'channelAccesses')]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[IdGroups(['Sync'])]
private ?ApiTokenInterface $token = null;
#[ORM\ManyToOne(targetEntity: ChannelInterface::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[IdGroups(['Sync'])]
private ?ChannelInterface $channel = null;
#[ORM\Column(options: ['default' => false])]
#[Serial\Groups(['Sync'])]
private bool $allUsersAllowed = false;
public static function getSyncKey(): string
{
return EntityKeys::DEVELOPERS_API_TOKEN_CHANNEL_ACCESS;
}
public function getSyncDisplayLabel(): string
{
return 'token channel access' . $this->getChannel();
}
}