src/Entity/System/Feature.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\System;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity()
  9. *
  10. * @ORM\Table(name="ps_feature")
  11. *
  12. * @ORM\Entity(repositoryClass="App\Repository\System\FeatureRepository")
  13. */
  14. class Feature
  15. {
  16. public const FEATURE_ACADEMY_COURSE_ID = 4907;
  17. public const FEATURE_ACADEMY_COURSE_LEVEL = 4915;
  18. public const FEATURE_ACADEMY_COURSE_LIFETIME = 4916;
  19. public const FEATURE_ACADEMY_COURSE_LESSONS = 4917;
  20. public const FEATURE_ACADEMY_COURSE_DURATION = 4918;
  21. public const FEATURE_ACADEMY_COURSE_SUBTITLES = 4919;
  22. public const FEATURE_ACADEMY_COURSE_TYPE = 4920;
  23. public const FEATURE_ACADEMY_COURSE_AUDIO = 4926;
  24. public const FEATURE_ACADEMY_COURSE_TYPE_ONBOARDING = 231154;
  25. public const FEATURE_ACADEMY_COURSE_TYPE_INTERNAL = 233082;
  26. public const FEATURE_ACADEMY_COURSE_TYPE_EXTERNAL = 233517;
  27. public const FEATURE_ACADEMY_COURSE_TYPE_REGISTRATION = 234032;
  28. public const FEATURE_COUNTRY_OF_ORIGIN = 279;
  29. public const FEATURE_PLUG_EU = 28017;
  30. public const FEATURE_ENERGY_EFFICIENCY = 96;
  31. public const FEATURES_INCLUDED_FOR_API = [
  32. self::FEATURE_COUNTRY_OF_ORIGIN,
  33. self::FEATURE_PLUG_EU,
  34. ];
  35. public const FEATURE_ACADEMY_IDS_EXCLUDED_FROM_PRODUCT_DETAIL = [
  36. self::FEATURE_ACADEMY_COURSE_ID,
  37. self::FEATURE_ACADEMY_COURSE_TYPE,
  38. ];
  39. public const FEATURE_ACADEMY_IDS_SORTING_FOR_PRODUCT_DETAIL = [
  40. self::FEATURE_ACADEMY_COURSE_LEVEL,
  41. self::FEATURE_ACADEMY_COURSE_DURATION,
  42. self::FEATURE_ACADEMY_COURSE_LESSONS,
  43. self::FEATURE_ACADEMY_COURSE_LIFETIME,
  44. self::FEATURE_ACADEMY_COURSE_AUDIO,
  45. self::FEATURE_ACADEMY_COURSE_SUBTITLES,
  46. ];
  47. /**
  48. * @var int
  49. *
  50. * @ORM\Id
  51. *
  52. * @ORM\GeneratedValue(strategy="AUTO")
  53. *
  54. * @ORM\Column(type="integer")
  55. */
  56. private $id;
  57. /**
  58. * @var string
  59. *
  60. * @ORM\Column(type="string", length=30)
  61. */
  62. private $reference;
  63. /**
  64. * @var \DateTime
  65. *
  66. * @ORM\Column(type="datetime")
  67. */
  68. private $dateAdd;
  69. /**
  70. * @var bool
  71. *
  72. * @ORM\Column(type="boolean")
  73. */
  74. private $active;
  75. /**
  76. * @var Collection<int, FeatureLang>&iterable<FeatureLang>
  77. *
  78. * @ORM\OneToMany(targetEntity="FeatureLang", mappedBy="feature")
  79. */
  80. private $featureLangs;
  81. /**
  82. * @var Collection<int, FeatureProduct>&iterable<FeatureProduct>
  83. *
  84. * @ORM\OneToMany(targetEntity="App\Entity\System\FeatureProduct", mappedBy="feature")
  85. */
  86. private $featureProducts;
  87. public function __construct()
  88. {
  89. $this->featureLangs = new ArrayCollection();
  90. $this->featureProducts = new ArrayCollection();
  91. }
  92. public function getId(): int
  93. {
  94. return $this->id;
  95. }
  96. public function getReference(): string
  97. {
  98. return $this->reference;
  99. }
  100. public function setReference(string $reference): Feature
  101. {
  102. $this->reference = $reference;
  103. return $this;
  104. }
  105. public function getDateAdd(): \DateTime
  106. {
  107. return $this->dateAdd;
  108. }
  109. public function setDateAdd(\DateTime $dateAdd): Feature
  110. {
  111. $this->dateAdd = $dateAdd;
  112. return $this;
  113. }
  114. public function isActive(): bool
  115. {
  116. return $this->active;
  117. }
  118. public function setActive(bool $active): Feature
  119. {
  120. $this->active = $active;
  121. return $this;
  122. }
  123. /**
  124. * @return Collection<int, FeatureLang>&iterable<FeatureLang>
  125. */
  126. public function getFeatureLangs()
  127. {
  128. return $this->featureLangs;
  129. }
  130. /**
  131. * @param Collection<int, FeatureLang>&iterable<FeatureLang> $featureLangs
  132. */
  133. public function setFeatureLangs($featureLangs): Feature
  134. {
  135. $this->featureLangs = $featureLangs;
  136. return $this;
  137. }
  138. /**
  139. * @return Collection<int, FeatureProduct>&iterable<FeatureProduct>
  140. */
  141. public function getFeatureProducts()
  142. {
  143. return $this->featureProducts;
  144. }
  145. /**
  146. * @param Collection<int, FeatureProduct>&iterable<FeatureProduct> $featureProducts
  147. *
  148. * @return Feature
  149. */
  150. public function setFeatureProducts($featureProducts)
  151. {
  152. $this->featureProducts = $featureProducts;
  153. return $this;
  154. }
  155. /**
  156. * @return array<string, FeatureLang>
  157. */
  158. public function getTranslationsIndexedByIsoCode(): array
  159. {
  160. $translations = [];
  161. foreach ($this->featureLangs as $translation) {
  162. $isoCode = strtolower($translation->getLanguage()->getIsoCode());
  163. $translations[$isoCode] = $translation;
  164. }
  165. return $translations;
  166. }
  167. }