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\OneToOne(inversedBy'channel'targetEntityChannelConfiguration::class, fetch'LAZY'orphanRemovaltrue)]
  91.     #[ORM\JoinColumn(nullabletrueonDelete'SET NULL')]
  92.     private ?ChannelConfiguration $configuration null;
  93.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  94.     private bool $enableScorm false;
  95.     /**
  96.      * Channel constructor.
  97.      */
  98.     public function __construct()
  99.     {
  100.         $this->institutions = new ArrayCollection();
  101.         $this->partners = new ArrayCollection();
  102.         $this->channelDescriptions = new ArrayCollection();
  103.         $this->galleryImages = new ArrayCollection();
  104.     }
  105.     public function isCanUploadVideo(): bool
  106.     {
  107.         return $this->canUploadVideo;
  108.     }
  109.     /**
  110.      * @return string|null
  111.      */
  112.     public function getDescription(): ?string
  113.     {
  114.         return $this->description;
  115.     }
  116.     /**
  117.      * @param string|null $description
  118.      *
  119.      * @return self
  120.      */
  121.     public function setDescription(?string $description)
  122.     {
  123.         $this->description $description;
  124.         return $this;
  125.     }
  126.     /**
  127.      * @return Link[]|Collection
  128.      */
  129.     public function getLinks()
  130.     {
  131.         return $this->links ?: $this->links = new ArrayCollection();
  132.     }
  133.     /**
  134.      * @param Link $link
  135.      *
  136.      * @return self
  137.      */
  138.     public function addLink(Link $link)
  139.     {
  140.         if (!$this->getLinks()->contains($link)) {
  141.             $this->getLinks()->add($link);
  142.             $link->setChannel($this);
  143.         }
  144.         return $this;
  145.     }
  146.     /**
  147.      * @param Link $link
  148.      * @return $this
  149.      */
  150.     public function removeLink(Link $link): self
  151.     {
  152.         if ($this->links->contains($link)) {
  153.             $this->links->removeElement($link);
  154.             // set the owning side to null (unless already changed)
  155.             if ($link->getChannel() === $this) {
  156.                 $link->setChannel(null);
  157.             }
  158.         }
  159.         return $this;
  160.     }
  161.     /**
  162.      * @return null|Image
  163.      */
  164.     public function getImage(): ?Image
  165.     {
  166.         return $this->image;
  167.     }
  168.     /**
  169.      * @param null|Image $image
  170.      * @return $this
  171.      */
  172.     public function setImage(?Image $image)
  173.     {
  174.         $this->image $image;
  175.         return $this;
  176.     }
  177.     /**
  178.      * @return Collection|Institution[]
  179.      */
  180.     public function getInstitutions(): Collection
  181.     {
  182.         return $this->institutions;
  183.     }
  184.     public function addInstitution(Institution $institution): self
  185.     {
  186.         if (!$this->institutions->contains($institution)) {
  187.             $this->institutions[] = $institution;
  188.             $institution->setChannel($this);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeInstitution(Institution $institution): self
  193.     {
  194.         if ($this->institutions->contains($institution)) {
  195.             $this->institutions->removeElement($institution);
  196.             // set the owning side to null (unless already changed)
  197.             if ($institution->getChannel() === $this) {
  198.                 $institution->setChannel(null);
  199.             }
  200.         }
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection|Partner[]
  205.      */
  206.     public function getPartners(): Collection
  207.     {
  208.         return $this->partners;
  209.     }
  210.     public function addPartner(Partner $partner): self
  211.     {
  212.         if (!$this->partners->contains($partner)) {
  213.             $this->partners[] = $partner;
  214.             $partner->setChannel($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removePartner(Partner $partner): self
  219.     {
  220.         if ($this->partners->contains($partner)) {
  221.             $this->partners->removeElement($partner);
  222.             // set the owning side to null (unless already changed)
  223.             if ($partner->getChannel() === $this) {
  224.                 $partner->setChannel(null);
  225.             }
  226.         }
  227.         return $this;
  228.     }
  229.     public function getContactEmail(): ?string
  230.     {
  231.         return $this->contactEmail;
  232.     }
  233.     public function setContactEmail(?string $contactEmail): self
  234.     {
  235.         $this->contactEmail $contactEmail;
  236.         return $this;
  237.     }
  238.     public function getContactPhone(): ?string
  239.     {
  240.         return $this->contactPhone;
  241.     }
  242.     public function setContactPhone(?string $contactPhone): self
  243.     {
  244.         $this->contactPhone $contactPhone;
  245.         return $this;
  246.     }
  247.     public function getPresentationTitle(): ?string
  248.     {
  249.         return $this->presentationTitle;
  250.     }
  251.     public function setPresentationTitle(?string $presentationTitle): self
  252.     {
  253.         $this->presentationTitle $presentationTitle;
  254.         return $this;
  255.     }
  256.     public function getPresentationText(): ?string
  257.     {
  258.         return $this->presentationText;
  259.     }
  260.     public function setPresentationText(?string $presentationText): self
  261.     {
  262.         $this->presentationText $presentationText;
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection|ChannelDescription[]
  267.      */
  268.     public function getChannelDescriptions(): Collection
  269.     {
  270.         return $this->channelDescriptions;
  271.     }
  272.     public function addChannelDescription(ChannelDescription $channelDescription): self
  273.     {
  274.         if (!$this->channelDescriptions->contains($channelDescription)) {
  275.             $this->channelDescriptions[] = $channelDescription;
  276.             $channelDescription->setChannel($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeChannelDescription(ChannelDescription $channelDescription): self
  281.     {
  282.         if ($this->channelDescriptions->contains($channelDescription)) {
  283.             $this->channelDescriptions->removeElement($channelDescription);
  284.             // set the owning side to null (unless already changed)
  285.             if ($channelDescription->getChannel() === $this) {
  286.                 $channelDescription->setChannel(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection|ChannelGallery[]
  293.      */
  294.     public function getGalleryImages(): Collection
  295.     {
  296.         return $this->galleryImages;
  297.     }
  298.     public function addGalleryImage(ChannelGallery $galleryImage): self
  299.     {
  300.         if (!$this->galleryImages->contains($galleryImage)) {
  301.             $this->galleryImages[] = $galleryImage;
  302.             $galleryImage->setChannel($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeGalleryImage(ChannelGallery $galleryImage): self
  307.     {
  308.         if ($this->galleryImages->contains($galleryImage)) {
  309.             $this->galleryImages->removeElement($galleryImage);
  310.             // set the owning side to null (unless already changed)
  311.             if ($galleryImage->getChannel() === $this) {
  312.                 $galleryImage->setChannel(null);
  313.             }
  314.         }
  315.         return $this;
  316.     }
  317.     public function countChannelUserDatas(): int
  318.     {
  319.         return $this->channelUserDatas->count();
  320.     }
  321.     public function getWhiteLabel(): ?ChannelWhiteLabel
  322.     {
  323.         return $this->channelWhiteLabel;
  324.     }
  325.     public function setChannelWhiteLabel(?ChannelWhiteLabel $channelWhiteLabel): Channel
  326.     {
  327.         $this->channelWhiteLabel $channelWhiteLabel;
  328.         return $this;
  329.     }
  330.     public function getConfiguration(): ?ChannelConfiguration
  331.     {
  332.         return $this->configuration;
  333.     }
  334.     public function setConfiguration(?ChannelConfiguration $configuration): static
  335.     {
  336.         $this->configuration $configuration;
  337.         return $this;
  338.     }
  339.     public function isEnableScorm(): bool
  340.     {
  341.         return $this->enableScorm;
  342.     }
  343.     public function setEnableScorm(bool $enableScorm): Channel
  344.     {
  345.         $this->enableScorm $enableScorm;
  346.         return $this;
  347.     }
  348. }