src/Entity/Channel/ChannelContact.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Common\Contact;
  4. use App\Entity\Sync\SyncableInterface;
  5. use App\Repository\Channel\ChannelContactRepository;
  6. use App\Validator\Constraints\UniqueEmailForChannelContactConstraint;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\ORM\Mapping\OneToMany;
  11. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  12. use Nellapp\Bundle\SDKBundle\Archivable\Entity\ArchivableTrait;
  13. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelContact\ChannelContactInterface;
  14. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelContact\ChannelContactMethodTrait;
  15. use Nellapp\Bundle\SDKBundle\Planning\Entity\PlanningResourceInterface;
  16. use Nellapp\Bundle\SDKBundle\Planning\Entity\PlanningResourceTrait;
  17. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  18. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  19. use Symfony\Component\Serializer\Annotation as Serial;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. #[
  22.     ORM\Entity(repositoryClassChannelContactRepository::class),
  23.     ORM\Table(name'channel_contacts'),
  24.     ORM\UniqueConstraint(fields: ['channel''contact']),
  25.     UniqueEntity(fields: ['channel''contact'], message'channel_contact.UniqueEntity')
  26. ]
  27. #[UniqueEmailForChannelContactConstraint]
  28. class ChannelContact implements SyncableInterfaceChannelContactInterfacePlanningResourceInterface
  29. {
  30.     use ArchivableTrait;
  31.     use ChannelContactMethodTrait;
  32.     use PlanningResourceTrait;
  33.     #[
  34.         ORM\Id,
  35.         ORM\GeneratedValue(strategy'NONE'),
  36.         ORM\Column(type'string'length36)
  37.     ]
  38.     #[Serial\Groups(['Sync''Manager'])]
  39.     private ?string $id null;
  40.     #[ORM\ManyToOne(targetEntityChannel::class)]
  41.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  42.     #[IdGroups(['Sync'])]
  43.     private ?Channel $channel null;
  44.     #[ORM\ManyToOne(targetEntityContact::class, cascade: ['persist'])]
  45.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  46.     #[IdGroups(['Sync'])]
  47.     #[Serial\Groups(['Manager'])]
  48.     #[
  49.         Assert\NotNull,
  50.         Assert\Valid(),
  51.     ]
  52.     private ?Contact $contact null;
  53.     #[OneToMany(mappedBy'channelContact'targetEntityCompanyContact::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  54.     private Collection $companyContacts;
  55.     public function __construct()
  56.     {
  57.         $this->initChannelContactMethod();
  58.         $this->companyContacts = new ArrayCollection();
  59.     }
  60.     public static function getSyncKey(): string
  61.     {
  62.         return EntityKeys::CHANNEL_CONTACT;
  63.     }
  64.     public function getSyncDisplayLabel(): string
  65.     {
  66.         return sprintf('Contact : %s pour la chaĆ®ne : %s '$this->contact$this->channel);
  67.     }
  68.     #[Serial\Groups(['Sync'])]
  69.     public function getArchivedAt(): ?\DateTimeImmutable
  70.     {
  71.         return $this->archivedAt;
  72.     }
  73. }