<?php
namespace App\Entity\Developers;
use App\Entity\Sync\SyncableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiClient\ApiClientInterface;
use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiClient\ApiClientMethodTrait;
use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiToken\ApiTokenInterface;
use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
use Symfony\Component\Serializer\Annotation as Serial;
#[ORM\Entity]
#[ORM\Table(name: 'developers_api_client')]
class ApiClient implements ApiClientInterface, TimestampInterface, SyncableInterface
{
use ApiClientMethodTrait;
use TimestampTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Serial\Groups(['Sync'])]
private ?int $id = null;
#[ORM\Column(length: 255, unique: true, nullable: false)]
#[Serial\Groups(['Sync'])]
private ?string $identifier = null;
#[ORM\Column(type: Types::BOOLEAN, nullable: false)]
#[Serial\Groups(['Sync'])]
private bool $active = true;
#[ORM\OneToMany(
mappedBy: 'client',
targetEntity: ApiTokenInterface::class,
cascade: ['persist', 'remove'],
orphanRemoval: true
)]
private Collection $tokens;
public function __construct() {
$this->tokens = new ArrayCollection();
}
public static function getSyncKey(): string
{
return EntityKeys::DEVELOPERS_API_CLIENT;
}
public function getSyncDisplayLabel(): string
{
return $this->getUsername();
}
}