src/Entity/Channel/UserFromChannel.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Account\User;
  4. use App\Entity\Sync\SyncableInterface;
  5. use App\Repository\Channel\UserFromChannelRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  8. use DrosalysWeb\ObjectExtensions\Blame\Model\CreatedBlameInterface;
  9. use DrosalysWeb\ObjectExtensions\Blame\Model\CreatedBlameTrait;
  10. use DrosalysWeb\ObjectExtensions\Timestamp\Model\CreatedTimestampInterface;
  11. use DrosalysWeb\ObjectExtensions\Timestamp\Model\CreatedTimestampTrait;
  12. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  13. use Symfony\Component\Serializer\Annotation as Serial;
  14. #[
  15. ORM\Entity(repositoryClass: UserFromChannelRepository::class),
  16. ORM\Table(name: 'channel_user_from_channels'),
  17. ]
  18. class UserFromChannel implements CreatedTimestampInterface, CreatedBlameInterface, SyncableInterface
  19. {
  20. use CreatedTimestampTrait;
  21. use CreatedBlameTrait;
  22. #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  23. #[Serial\Groups(['Manager', 'Sync'])]
  24. private ?int $id = null;
  25. #[ORM\OneToOne(inversedBy: 'userFromChannel', targetEntity: User::class)]
  26. #[Serial\Groups(['Manager'])]
  27. #[IdGroups(['Sync'])]
  28. private ?User $user = null;
  29. #[ORM\ManyToOne(targetEntity: Channel::class), ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  30. #[Serial\Groups(['Manager'])]
  31. #[IdGroups(['Sync'])]
  32. private ?Channel $channel = null;
  33. public static function getSyncKey(): string
  34. {
  35. return EntityKeys::CHANNEL_USER_FROM_CHANNEL;
  36. }
  37. public function getSyncDisplayLabel(): string
  38. {
  39. return $this->getUser();
  40. }
  41. public function getId(): ?int
  42. {
  43. return $this->id;
  44. }
  45. public function getUser(): ?User
  46. {
  47. return $this->user;
  48. }
  49. public function setUser(?User $user): static
  50. {
  51. $this->user = $user;
  52. return $this;
  53. }
  54. public function getChannel(): ?Channel
  55. {
  56. return $this->channel;
  57. }
  58. public function setChannel(?Channel $channel): static
  59. {
  60. $this->channel = $channel;
  61. return $this;
  62. }
  63. }