src/Entity/Channel/Channel.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel;
  3. use App\Entity\Account\User;
  4. use App\Entity\Common\Contact;
  5. use App\Repository\Channel\ChannelRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  10. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelMethodTrait;
  11. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelPropertyTrait;
  12. use Symfony\Component\Serializer\Annotation as Serial;
  13. #[ORM\Entity(repositoryClassChannelRepository::class)]
  14. #[ORM\Table(name'channel_channels')]
  15. class Channel implements ChannelInterface
  16. {
  17.     use ChannelMethodTrait;
  18.     use ChannelPropertyTrait;
  19.     #[ORM\IdORM\Column(type'string'length36)]
  20.     #[Serial\Groups(['GlobalJSVariable'])]
  21.     private ?string $id null;
  22.     #[ORM\Column(type'string')]
  23.     #[Serial\Groups(['GlobalJSVariable'])]
  24.     private ?string $name null;
  25.     #[ORM\Column(type'string'nullabletrue)]
  26.     private ?string $imagePath null;
  27.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  28.     private bool $paymentAlert false;
  29.     #[ORM\ManyToOne(targetEntityUser::class)]
  30.     private ?User $owner null;
  31.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  32.     private bool $enabledIndexing false;
  33.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  34.     private bool $enabledChatBot false;
  35.     #[ORM\OneToOne(inversedBy'channel'targetEntityChannelConfiguration::class, fetch'LAZY'orphanRemovaltrue)]
  36.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  37.     private ?ChannelConfiguration $configuration null;
  38.     #[ORM\ManyToMany(targetEntityContact::class, mappedBy'channels')]
  39.     private Collection $contacts;
  40.     #[ORM\OneToMany(mappedBy'channel'targetEntityDrive::class)]
  41.     private Collection $drives;
  42.     public function __construct()
  43.     {
  44.         $this->contacts = new ArrayCollection();
  45.         $this->drives = new ArrayCollection();
  46.     }
  47.     public function getConfiguration(): ?ChannelConfiguration
  48.     {
  49.         return $this->configuration;
  50.     }
  51.     public function setConfiguration(?ChannelConfiguration $configuration): static
  52.     {
  53.         $this->configuration $configuration;
  54.         return $this;
  55.     }
  56.     public function getContacts(): Collection
  57.     {
  58.         return $this->contacts ?? $this->contacts = new ArrayCollection();
  59.     }
  60.     public function setContacts(Collection $contacts): static
  61.     {
  62.         $this->contacts $contacts;
  63.         return $this;
  64.     }
  65.     public function addContact(Contact $contact): static
  66.     {
  67.         $contacts $this->getContacts();
  68.         if (!$contacts->contains($contact)) {
  69.             $contacts->add($contact);
  70.             $contact->addChannel($this);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeContact(Contact $contact): static
  75.     {
  76.         $contacts $this->getContacts();
  77.         if ($contacts->contains($contact)) {
  78.             $contacts->removeElement($contact);
  79.             $contact->removeChannel($this);
  80.         }
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return Collection<int, Drive>
  85.      */
  86.     public function getDrives(): Collection
  87.     {
  88.         return $this->drives;
  89.     }
  90.     public function addDrive(Drive $drive): static
  91.     {
  92.         if (!$this->drives->contains($drive)) {
  93.             $this->drives->add($drive);
  94.             $drive->setChannel($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeDrive(Drive $drive): static
  99.     {
  100.         if ($this->drives->removeElement($drive)) {
  101.             // set the owning side to null (unless already changed)
  102.             if ($drive->getChannel() === $this) {
  103.                 $drive->setChannel(null);
  104.             }
  105.         }
  106.         return $this;
  107.     }
  108. }