src/Entity/Channel/Channel.php line 32

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