src/Entity/Developers/ApiClient.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Developers;
  3. use App\Entity\Sync\SyncableInterface;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
  9. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
  10. use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiClient\ApiClientInterface;
  11. use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiClient\ApiClientMethodTrait;
  12. use Nellapp\Bundle\SDKBundle\Developers\Entity\ApiToken\ApiTokenInterface;
  13. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  14. use Symfony\Component\Serializer\Annotation as Serial;
  15. #[ORM\Entity]
  16. #[ORM\Table(name: 'developers_api_client')]
  17. class ApiClient implements ApiClientInterface, TimestampInterface, SyncableInterface
  18. {
  19. use ApiClientMethodTrait;
  20. use TimestampTrait;
  21. #[ORM\Id]
  22. #[ORM\GeneratedValue]
  23. #[ORM\Column]
  24. #[Serial\Groups(['Sync'])]
  25. private ?int $id = null;
  26. #[ORM\Column(length: 255, unique: true, nullable: false)]
  27. #[Serial\Groups(['Sync'])]
  28. private ?string $identifier = null;
  29. #[ORM\Column(type: Types::BOOLEAN, nullable: false)]
  30. #[Serial\Groups(['Sync'])]
  31. private bool $active = true;
  32. #[ORM\OneToMany(
  33. mappedBy: 'client',
  34. targetEntity: ApiTokenInterface::class,
  35. cascade: ['persist', 'remove'],
  36. orphanRemoval: true
  37. )]
  38. private Collection $tokens;
  39. public function __construct() {
  40. $this->tokens = new ArrayCollection();
  41. }
  42. public static function getSyncKey(): string
  43. {
  44. return EntityKeys::DEVELOPERS_API_CLIENT;
  45. }
  46. public function getSyncDisplayLabel(): string
  47. {
  48. return $this->getUsername();
  49. }
  50. }