src/Entity/Channel/Channel.php line 31

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the adrec/platform-api package.
  4.  *
  5.  * (c) Benjamin Georgeault
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Entity\Channel;
  11. use App\Entity\Account\User;
  12. use App\Entity\Channel\Partner\Partner;
  13. use App\Entity\ChannelUserData\ChannelUserData;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  17. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelMethodTrait;
  18. use App\Repository\Channel\ChannelRepository;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Symfony\Component\Serializer\Annotation as Serial;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. #[
  23.     ORM\Entity(repositoryClassChannelRepository::class),
  24.     ORM\Table(name'channel_channels'),
  25.     ORM\Index(columns: ['name'], flags: ['fulltext']),
  26.     ORM\Index(columns: ['description'], flags: ['fulltext']),
  27. ]
  28. class Channel implements ChannelInterface
  29. {
  30.     use ChannelMethodTrait;
  31.     #[ORM\IdORM\Column(type'string'length36)]
  32.     #[Serial\Groups(['Manager'])]
  33.     private ?string $id null;
  34.     #[ORM\Column(type'string')]
  35.     #[Serial\Groups(['Manager'])]
  36.     private ?string $name null;
  37.     #[ORM\Column(type'string'nullabletrue)]
  38.     #[Serial\Groups(['Manager'])]
  39.     private ?string $slogan null;
  40.     #[ORM\Column(type'boolean'nullablefalse)]
  41.     private bool $approved false;
  42.     #[ORM\ManyToOne(targetEntityUser::class)]
  43.     private ?User $owner null;
  44.     #[ORM\Column(type'boolean'nullablefalse)]
  45.     private bool $canShareContent false;
  46.     #[ORM\Column(type'boolean'nullablefalse)]
  47.     private bool $canUploadVideo false;
  48.     #[ORM\Column(type'string'nullabletrue)]
  49.     private ?string $imagePath null;
  50.     #[ORM\Column(type'text'nullabletrue)]
  51.     #[Assert\Length(
  52.         min:20,
  53.         max2000,
  54.         minMessage'channel.channel.description.Length.min',
  55.         maxMessage'channel.channel.description.Length.max'
  56.     )]
  57.     private ?string $description null;
  58.     #[ORM\OneToMany(mappedBy'channel'targetEntityLink::class, cascade: ['persist''remove'], fetch"EXTRA_LAZY"orphanRemovaltrue)]
  59.     private $links null;
  60.     #[ORM\ManyToOne(targetEntityImage::class)]
  61.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  62.     private ?Image $image null;
  63.     #[ORM\OneToMany(mappedBy'channel'targetEntityInstitution::class, cascade: ['persist''remove'], fetch"EXTRA_LAZY"orphanRemovaltrue)]
  64.     private $institutions;
  65.     #[ORM\OneToMany(mappedBy'channel'targetEntityPartner::class, cascade: ['persist''remove'], fetch"EXTRA_LAZY"orphanRemovaltrue)]
  66.     private $partners;
  67.     #[ORM\Column(type'string'length255nullabletrue)]
  68.     private $contactEmail;
  69.     #[ORM\Column(type'string'length255nullabletrue)]
  70.     private $contactPhone;
  71.     #[ORM\Column(type'string'length255nullabletrue)]
  72.     private $presentationTitle;
  73.     #[ORM\Column(type'text'nullabletrue)]
  74.     private $presentationText;
  75.     #[ORM\OneToMany(mappedBy'channel'targetEntityChannelDescription::class, cascade: ['persist''remove'], fetch"EXTRA_LAZY"orphanRemovaltrue)]
  76.     private $channelDescriptions;
  77.     #[ORM\OneToMany(mappedBy'channel'targetEntityChannelGallery::class, cascade: ['persist''remove'], fetch"EXTRA_LAZY"orphanRemovaltrue)]
  78.     #[ORM\OrderBy(['displayOrder' => 'ASC'])]
  79.     private $galleryImages;
  80.     #[ORM\OneToMany(mappedBy'channel'targetEntityChannelUserData::class, fetch"EXTRA_LAZY")]
  81.     private Collection $channelUserDatas;
  82.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  83.     private bool $paymentAlert false;
  84.     #[ORM\OneToOne(mappedBy'channel'targetEntityChannelWhiteLabel::class)]
  85.     private ?ChannelWhiteLabel $channelWhiteLabel null;
  86.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  87.     private bool $enabledIndexing false;
  88.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  89.     private bool $enabledChatBot false;
  90.     #[ORM\ManyToOne(targetEntityUser::class)]
  91.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  92.     private ?User $defaultReferralTrainer null;
  93.     /**
  94.      * Channel constructor.
  95.      */
  96.     public function __construct()
  97.     {
  98.         $this->institutions = new ArrayCollection();
  99.         $this->partners = new ArrayCollection();
  100.         $this->channelDescriptions = new ArrayCollection();
  101.         $this->galleryImages = new ArrayCollection();
  102.     }
  103.     public function isCanUploadVideo(): bool
  104.     {
  105.         return $this->canUploadVideo;
  106.     }
  107.     /**
  108.      * @return string|null
  109.      */
  110.     public function getDescription(): ?string
  111.     {
  112.         return $this->description;
  113.     }
  114.     /**
  115.      * @param string|null $description
  116.      *
  117.      * @return self
  118.      */
  119.     public function setDescription(?string $description)
  120.     {
  121.         $this->description $description;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Link[]|Collection
  126.      */
  127.     public function getLinks()
  128.     {
  129.         return $this->links ?: $this->links = new ArrayCollection();
  130.     }
  131.     /**
  132.      * @param Link $link
  133.      *
  134.      * @return self
  135.      */
  136.     public function addLink(Link $link)
  137.     {
  138.         if (!$this->getLinks()->contains($link)) {
  139.             $this->getLinks()->add($link);
  140.             $link->setChannel($this);
  141.         }
  142.         return $this;
  143.     }
  144.     /**
  145.      * @param Link $link
  146.      * @return $this
  147.      */
  148.     public function removeLink(Link $link): self
  149.     {
  150.         if ($this->links->contains($link)) {
  151.             $this->links->removeElement($link);
  152.             // set the owning side to null (unless already changed)
  153.             if ($link->getChannel() === $this) {
  154.                 $link->setChannel(null);
  155.             }
  156.         }
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return null|Image
  161.      */
  162.     public function getImage(): ?Image
  163.     {
  164.         return $this->image;
  165.     }
  166.     /**
  167.      * @param null|Image $image
  168.      * @return $this
  169.      */
  170.     public function setImage(?Image $image)
  171.     {
  172.         $this->image $image;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return Collection|Institution[]
  177.      */
  178.     public function getInstitutions(): Collection
  179.     {
  180.         return $this->institutions;
  181.     }
  182.     public function addInstitution(Institution $institution): self
  183.     {
  184.         if (!$this->institutions->contains($institution)) {
  185.             $this->institutions[] = $institution;
  186.             $institution->setChannel($this);
  187.         }
  188.         return $this;
  189.     }
  190.     public function removeInstitution(Institution $institution): self
  191.     {
  192.         if ($this->institutions->contains($institution)) {
  193.             $this->institutions->removeElement($institution);
  194.             // set the owning side to null (unless already changed)
  195.             if ($institution->getChannel() === $this) {
  196.                 $institution->setChannel(null);
  197.             }
  198.         }
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return Collection|Partner[]
  203.      */
  204.     public function getPartners(): Collection
  205.     {
  206.         return $this->partners;
  207.     }
  208.     public function addPartner(Partner $partner): self
  209.     {
  210.         if (!$this->partners->contains($partner)) {
  211.             $this->partners[] = $partner;
  212.             $partner->setChannel($this);
  213.         }
  214.         return $this;
  215.     }
  216.     public function removePartner(Partner $partner): self
  217.     {
  218.         if ($this->partners->contains($partner)) {
  219.             $this->partners->removeElement($partner);
  220.             // set the owning side to null (unless already changed)
  221.             if ($partner->getChannel() === $this) {
  222.                 $partner->setChannel(null);
  223.             }
  224.         }
  225.         return $this;
  226.     }
  227.     public function getContactEmail(): ?string
  228.     {
  229.         return $this->contactEmail;
  230.     }
  231.     public function setContactEmail(?string $contactEmail): self
  232.     {
  233.         $this->contactEmail $contactEmail;
  234.         return $this;
  235.     }
  236.     public function getContactPhone(): ?string
  237.     {
  238.         return $this->contactPhone;
  239.     }
  240.     public function setContactPhone(?string $contactPhone): self
  241.     {
  242.         $this->contactPhone $contactPhone;
  243.         return $this;
  244.     }
  245.     public function getPresentationTitle(): ?string
  246.     {
  247.         return $this->presentationTitle;
  248.     }
  249.     public function setPresentationTitle(?string $presentationTitle): self
  250.     {
  251.         $this->presentationTitle $presentationTitle;
  252.         return $this;
  253.     }
  254.     public function getPresentationText(): ?string
  255.     {
  256.         return $this->presentationText;
  257.     }
  258.     public function setPresentationText(?string $presentationText): self
  259.     {
  260.         $this->presentationText $presentationText;
  261.         return $this;
  262.     }
  263.     /**
  264.      * @return Collection|ChannelDescription[]
  265.      */
  266.     public function getChannelDescriptions(): Collection
  267.     {
  268.         return $this->channelDescriptions;
  269.     }
  270.     public function addChannelDescription(ChannelDescription $channelDescription): self
  271.     {
  272.         if (!$this->channelDescriptions->contains($channelDescription)) {
  273.             $this->channelDescriptions[] = $channelDescription;
  274.             $channelDescription->setChannel($this);
  275.         }
  276.         return $this;
  277.     }
  278.     public function removeChannelDescription(ChannelDescription $channelDescription): self
  279.     {
  280.         if ($this->channelDescriptions->contains($channelDescription)) {
  281.             $this->channelDescriptions->removeElement($channelDescription);
  282.             // set the owning side to null (unless already changed)
  283.             if ($channelDescription->getChannel() === $this) {
  284.                 $channelDescription->setChannel(null);
  285.             }
  286.         }
  287.         return $this;
  288.     }
  289.     /**
  290.      * @return Collection|ChannelGallery[]
  291.      */
  292.     public function getGalleryImages(): Collection
  293.     {
  294.         return $this->galleryImages;
  295.     }
  296.     public function addGalleryImage(ChannelGallery $galleryImage): self
  297.     {
  298.         if (!$this->galleryImages->contains($galleryImage)) {
  299.             $this->galleryImages[] = $galleryImage;
  300.             $galleryImage->setChannel($this);
  301.         }
  302.         return $this;
  303.     }
  304.     public function removeGalleryImage(ChannelGallery $galleryImage): self
  305.     {
  306.         if ($this->galleryImages->contains($galleryImage)) {
  307.             $this->galleryImages->removeElement($galleryImage);
  308.             // set the owning side to null (unless already changed)
  309.             if ($galleryImage->getChannel() === $this) {
  310.                 $galleryImage->setChannel(null);
  311.             }
  312.         }
  313.         return $this;
  314.     }
  315.     public function countChannelUserDatas(): int
  316.     {
  317.         return $this->channelUserDatas->count();
  318.     }
  319.     public function getWhiteLabel(): ?ChannelWhiteLabel
  320.     {
  321.         return $this->channelWhiteLabel;
  322.     }
  323.     public function setChannelWhiteLabel(?ChannelWhiteLabel $channelWhiteLabel): Channel
  324.     {
  325.         $this->channelWhiteLabel $channelWhiteLabel;
  326.         return $this;
  327.     }
  328.     public function getDefaultReferralTrainer(): ?User
  329.     {
  330.         return $this->defaultReferralTrainer;
  331.     }
  332.     public function setDefaultReferralTrainer(?User $defaultReferralTrainer): Channel
  333.     {
  334.         $this->defaultReferralTrainer $defaultReferralTrainer;
  335.         return $this;
  336.     }
  337. }