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_TYPE_ONBOARDING = 231154;
  17. public const FEATURE_ACADEMY_COURSE_TYPE_REGISTRATION = 234032;
  18. public const FEATURE_COUNTRY_OF_ORIGIN = 279;
  19. public const FEATURE_PLUG_EU = 28017;
  20. public const FEATURE_ENERGY_EFFICIENCY = 96;
  21. public const EXCLUDED_ACADEMY_PRODUCT_FEATURE_VALUE = [
  22. self::FEATURE_ACADEMY_COURSE_TYPE_REGISTRATION,
  23. self::FEATURE_ACADEMY_COURSE_TYPE_ONBOARDING,
  24. ];
  25. public const FEATURES_INCLUDED_FOR_API = [
  26. self::FEATURE_COUNTRY_OF_ORIGIN,
  27. self::FEATURE_PLUG_EU,
  28. ];
  29. /**
  30. * @var int
  31. *
  32. * @ORM\Id
  33. *
  34. * @ORM\GeneratedValue(strategy="AUTO")
  35. *
  36. * @ORM\Column(type="integer")
  37. */
  38. private $id;
  39. /**
  40. * @var string
  41. *
  42. * @ORM\Column(type="string", length=30)
  43. */
  44. private $reference;
  45. /**
  46. * @var \DateTime
  47. *
  48. * @ORM\Column(type="datetime")
  49. */
  50. private $dateAdd;
  51. /**
  52. * @var bool
  53. *
  54. * @ORM\Column(type="boolean")
  55. */
  56. private $active;
  57. /**
  58. * @var Collection<int, FeatureLang>&iterable<FeatureLang>
  59. *
  60. * @ORM\OneToMany(targetEntity="FeatureLang", mappedBy="feature")
  61. */
  62. private $featureLangs;
  63. /**
  64. * @var Collection<int, FeatureProduct>&iterable<FeatureProduct>
  65. *
  66. * @ORM\OneToMany(targetEntity="App\Entity\System\FeatureProduct", mappedBy="feature")
  67. */
  68. private $featureProducts;
  69. public function __construct()
  70. {
  71. $this->featureLangs = new ArrayCollection();
  72. $this->featureProducts = new ArrayCollection();
  73. }
  74. public function getId(): int
  75. {
  76. return $this->id;
  77. }
  78. public function getReference(): string
  79. {
  80. return $this->reference;
  81. }
  82. public function setReference(string $reference): Feature
  83. {
  84. $this->reference = $reference;
  85. return $this;
  86. }
  87. public function getDateAdd(): \DateTime
  88. {
  89. return $this->dateAdd;
  90. }
  91. public function setDateAdd(\DateTime $dateAdd): Feature
  92. {
  93. $this->dateAdd = $dateAdd;
  94. return $this;
  95. }
  96. public function isActive(): bool
  97. {
  98. return $this->active;
  99. }
  100. public function setActive(bool $active): Feature
  101. {
  102. $this->active = $active;
  103. return $this;
  104. }
  105. /**
  106. * @return Collection<int, FeatureLang>&iterable<FeatureLang>
  107. */
  108. public function getFeatureLangs()
  109. {
  110. return $this->featureLangs;
  111. }
  112. /**
  113. * @param Collection<int, FeatureLang>&iterable<FeatureLang> $featureLangs
  114. */
  115. public function setFeatureLangs($featureLangs): Feature
  116. {
  117. $this->featureLangs = $featureLangs;
  118. return $this;
  119. }
  120. /**
  121. * @return Collection<int, FeatureProduct>&iterable<FeatureProduct>
  122. */
  123. public function getFeatureProducts()
  124. {
  125. return $this->featureProducts;
  126. }
  127. /**
  128. * @param Collection<int, FeatureProduct>&iterable<FeatureProduct> $featureProducts
  129. *
  130. * @return Feature
  131. */
  132. public function setFeatureProducts($featureProducts)
  133. {
  134. $this->featureProducts = $featureProducts;
  135. return $this;
  136. }
  137. /**
  138. * @return array<string, FeatureLang>
  139. */
  140. public function getTranslationsIndexedByIsoCode(): array
  141. {
  142. $translations = [];
  143. foreach ($this->featureLangs as $translation) {
  144. $isoCode = strtolower($translation->getLanguage()->getIsoCode());
  145. $translations[$isoCode] = $translation;
  146. }
  147. return $translations;
  148. }
  149. }