src/Entity/Channel/ChannelWhiteLabel.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Sync\SyncableInterface;
  4. use App\Repository\Channel\ChannelWhiteLabelRepository;
  5. use App\Validator\Constraints\DomainResolutionConstraint;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  8. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelWhiteLabel\ChannelWhiteLabelInterface;
  9. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelWhiteLabel\ChannelWhiteLabelMethodTrait;
  10. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  11. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. use Symfony\Component\Serializer\Annotation as Serial;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. #[ORM\Entity(repositoryClassChannelWhiteLabelRepository::class)]
  16. #[UniqueEntity(fields: ['domain'], message'dns.domain.unique')]
  17. #[ORM\UniqueConstraint(fields: ['domain'])]
  18. class ChannelWhiteLabel implements ChannelWhiteLabelInterfaceSyncableInterface
  19. {
  20.     use ChannelWhiteLabelMethodTrait;
  21.     #[ORM\IdORM\GeneratedValue(strategy'CUSTOM'), ORM\CustomIdGenerator(class: UuidGenerator::class), ORM\Column(type'string'length36)]
  22.     #[Serial\Groups(['Sync'])]
  23.     private ?string $id null;
  24.     #[ORM\OneToOne(inversedBy'whiteLabel'targetEntityChannel::class)]
  25.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  26.     #[IdGroups(groups: ['Sync'])]
  27.     private ?Channel $channel null;
  28.     #[ORM\Column(type'string'length255nullablefalse)]
  29.     #[
  30.         Assert\NotBlank(),
  31.         Assert\Length(min2max255),
  32.         DomainResolutionConstraint
  33.     ]
  34.     #[Serial\Groups(['Sync'])]
  35.     private ?string $domain null;
  36.     public static function getSyncKey(): string
  37.     {
  38.         return EntityKeys::CHANNEL_WHITE_LABEL;
  39.     }
  40.     public function getSyncDisplayLabel(): string
  41.     {
  42.         return $this->getChannel() . ' - ' $this->getDomain();
  43.     }
  44. }