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