src/Entity/Channel/ChannelContact.php line 30

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\Planning\Entity\PlanningResourceInterface;
  15. use Nellapp\Bundle\SDKBundle\Planning\Entity\PlanningResourceTrait;
  16. use Nellapp\Bundle\SDKBundle\Sync\EntityKeys;
  17. use Override;
  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. class ChannelContact implements SyncableInterfaceChannelContactInterfacePlanningResourceInterface
  28. {
  29.     use ArchivableTrait;
  30.     use ChannelContactMethodTrait;
  31.     use PlanningResourceTrait;
  32.     #[
  33.         ORM\Id,
  34.         ORM\GeneratedValue(strategy'NONE'),
  35.         ORM\Column(type'string'length36)
  36.     ]
  37.     #[Serial\Groups(['Sync''Manager'])]
  38.     private ?string $id null;
  39.     #[ORM\ManyToOne(targetEntityChannel::class)]
  40.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  41.     #[IdGroups(['Sync'])]
  42.     private ?Channel $channel null;
  43.     #[ORM\ManyToOne(targetEntityContact::class, cascade: ['persist'])]
  44.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  45.     #[IdGroups(['Sync'])]
  46.     #[Serial\Groups(['Manager'])]
  47.     #[
  48.         Assert\NotNull,
  49.         Assert\Valid(),
  50.     ]
  51.     private ?Contact $contact null;
  52.     #[OneToMany(mappedBy'channelContact'targetEntityCompanyContact::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  53.     private Collection $companyContacts;
  54.     public function __construct()
  55.     {
  56.         $this->initChannelContactMethod();
  57.         $this->companyContacts = new ArrayCollection();
  58.     }
  59.     public static function getSyncKey(): string
  60.     {
  61.         return EntityKeys::CHANNEL_CONTACT;
  62.     }
  63.     public function getSyncDisplayLabel(): string
  64.     {
  65.         return sprintf('Contact : %s pour la chaĆ®ne : %s '$this->contact$this->channel);
  66.     }
  67.     #[Serial\Groups(['Sync'])]
  68.     public function getArchivedAt(): ?\DateTimeImmutable
  69.     {
  70.         return $this->archivedAt;
  71.     }
  72. }