src/Entity/Channel/ChannelContact.php line 26

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