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\Bunny\BunnyVideoCollection;
  13. use App\Entity\Channel\Partner\Partner;
  14. use App\Entity\ChannelUserData\ChannelUserData;
  15. use Doctrine\Common\Collections\ArrayCollection;
  16. use Doctrine\Common\Collections\Collection;
  17. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelInterface;
  18. use Nellapp\Bundle\SDKBundle\Channel\Entity\ChannelMethodTrait;
  19. use App\Repository\Channel\ChannelRepository;
  20. use Doctrine\ORM\Mapping as ORM;
  21. use Symfony\Component\Serializer\Annotation as Serial;
  22. use Symfony\Component\Validator\Constraints as Assert;
  23. #[
  24. ORM\Entity(repositoryClass: ChannelRepository::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\Id, ORM\Column(type: 'string', length: 36)]
  33. #[Serial\Groups(['Manager', 'GlobalJSVariable'])]
  34. private ?string $id = null;
  35. #[ORM\Column(type: 'string')]
  36. #[Serial\Groups(['Manager'])]
  37. private ?string $name = null;
  38. #[ORM\Column(type: 'string', nullable: true)]
  39. #[Serial\Groups(['Manager'])]
  40. private ?string $slogan = null;
  41. #[ORM\Column(type: 'boolean', nullable: false)]
  42. private bool $approved = false;
  43. #[ORM\ManyToOne(targetEntity: User::class)]
  44. private ?User $owner = null;
  45. #[ORM\Column(type: 'boolean', nullable: false)]
  46. private bool $canShareContent = false;
  47. #[ORM\Column(type: 'string', nullable: true)]
  48. private ?string $imagePath = null;
  49. #[ORM\Column(type: 'text', nullable: true)]
  50. #[Assert\Length(
  51. min:20,
  52. max: 2000,
  53. minMessage: 'channel.channel.description.Length.min',
  54. maxMessage: 'channel.channel.description.Length.max'
  55. )]
  56. private ?string $description = null;
  57. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: Link::class, cascade: ['persist', 'remove'], fetch: "EXTRA_LAZY", orphanRemoval: true)]
  58. private $links = null;
  59. #[ORM\ManyToOne(targetEntity: Image::class)]
  60. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  61. private ?Image $image = null;
  62. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: Institution::class, cascade: ['persist', 'remove'], fetch: "EXTRA_LAZY", orphanRemoval: true)]
  63. private $institutions;
  64. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: Partner::class, cascade: ['persist', 'remove'], fetch: "EXTRA_LAZY", orphanRemoval: true)]
  65. private $partners;
  66. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  67. private $contactEmail;
  68. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  69. private $contactPhone;
  70. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  71. private $presentationTitle;
  72. #[ORM\Column(type: 'text', nullable: true)]
  73. private $presentationText;
  74. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: ChannelDescription::class, cascade: ['persist', 'remove'], fetch: "EXTRA_LAZY", orphanRemoval: true)]
  75. private $channelDescriptions;
  76. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: ChannelGallery::class, cascade: ['persist', 'remove'], fetch: "EXTRA_LAZY", orphanRemoval: true)]
  77. #[ORM\OrderBy(['displayOrder' => 'ASC'])]
  78. private $galleryImages;
  79. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: ChannelUserData::class, fetch: "EXTRA_LAZY")]
  80. private Collection $channelUserDatas;
  81. #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  82. private bool $paymentAlert = false;
  83. #[ORM\OneToOne(mappedBy: 'channel', targetEntity: ChannelWhiteLabel::class)]
  84. private ?ChannelWhiteLabel $channelWhiteLabel = null;
  85. #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  86. private bool $enabledIndexing = false;
  87. #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  88. private bool $enabledChatBot = false;
  89. #[ORM\OneToOne(inversedBy: 'channel', targetEntity: ChannelConfiguration::class, fetch: 'LAZY', orphanRemoval: true)]
  90. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  91. private ?ChannelConfiguration $configuration = null;
  92. #[ORM\Column(type: 'boolean', nullable: false, options: ['default' => false])]
  93. private bool $enableScorm = false;
  94. /**
  95. * @var Collection<int, BunnyVideoCollection>
  96. */
  97. #[ORM\OneToMany(mappedBy: 'channel', targetEntity: BunnyVideoCollection::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  98. private Collection $bunnyVideoCollections;
  99. /**
  100. * Channel constructor.
  101. */
  102. public function __construct()
  103. {
  104. $this->institutions = new ArrayCollection();
  105. $this->partners = new ArrayCollection();
  106. $this->channelDescriptions = new ArrayCollection();
  107. $this->galleryImages = new ArrayCollection();
  108. $this->bunnyVideoCollections = new ArrayCollection();
  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(): ?ChannelConfiguration
  332. {
  333. return $this->configuration;
  334. }
  335. public function setConfiguration(?ChannelConfiguration $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. /**
  350. * @return Collection<int, BunnyVideoCollection>
  351. */
  352. public function getVideoCollections(): Collection
  353. {
  354. return $this->bunnyVideoCollections;
  355. }
  356. public function addVideoCollection(BunnyVideoCollection $videoCollection): static
  357. {
  358. if (!$this->bunnyVideoCollections->contains($videoCollection)) {
  359. $this->bunnyVideoCollections->add($videoCollection);
  360. $videoCollection->setChannel($this);
  361. }
  362. return $this;
  363. }
  364. public function removeVideoCollection(BunnyVideoCollection $videoCollection): static
  365. {
  366. $this->bunnyVideoCollections->removeElement($videoCollection);
  367. return $this;
  368. }
  369. }