src/Entity/System/FeatureValue.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_value")
  11. *
  12. * @ORM\Entity(repositoryClass="App\Repository\System\FeatureValueRepository")
  13. */
  14. class FeatureValue
  15. {
  16. /**
  17. * @var int
  18. *
  19. * @ORM\Id
  20. *
  21. * @ORM\GeneratedValue(strategy="AUTO")
  22. *
  23. * @ORM\Column(type="integer")
  24. */
  25. private $id;
  26. /**
  27. * @var string
  28. *
  29. * @ORM\Column(type="string", length=30)
  30. */
  31. private $reference;
  32. /**
  33. * @var Feature
  34. *
  35. * @ORM\ManyToOne(targetEntity="Feature")
  36. *
  37. * @ORM\JoinColumn(name="id_feature", referencedColumnName="id")
  38. */
  39. private $feature;
  40. /**
  41. * @var Collection<int, FeatureValueLang>|FeatureValueLang[]
  42. *
  43. * @ORM\OneToMany(targetEntity="FeatureValueLang", mappedBy="featureValue")
  44. */
  45. private $featureValueLangs;
  46. public function __construct()
  47. {
  48. $this->featureValueLangs = new ArrayCollection();
  49. }
  50. public function getId(): int
  51. {
  52. return $this->id;
  53. }
  54. public function getReference(): string
  55. {
  56. return $this->reference;
  57. }
  58. public function setReference(string $reference): FeatureValue
  59. {
  60. $this->reference = $reference;
  61. return $this;
  62. }
  63. public function getFeature(): Feature
  64. {
  65. return $this->feature;
  66. }
  67. public function setFeature(Feature $feature): FeatureValue
  68. {
  69. $this->feature = $feature;
  70. return $this;
  71. }
  72. /**
  73. * @return Collection<int, FeatureValueLang>|FeatureValueLang[]
  74. */
  75. public function getFeatureValueLangs()
  76. {
  77. return $this->featureValueLangs;
  78. }
  79. /**
  80. * @param Collection<int, FeatureValueLang>|FeatureValueLang[] $featureValueLangs
  81. */
  82. public function setFeatureValueLangs($featureValueLangs): FeatureValue
  83. {
  84. $this->featureValueLangs = $featureValueLangs;
  85. return $this;
  86. }
  87. /**
  88. * @return Collection<string, FeatureValueLang>|array<string, FeatureValueLang>
  89. */
  90. public function getTranslationsIndexedByIsoCode(): array
  91. {
  92. $translations = [];
  93. foreach ($this->featureValueLangs as $translation) {
  94. $isoCode = strtolower($translation->getLanguage()->getIsoCode());
  95. $translations[$isoCode] = $translation;
  96. }
  97. return $translations;
  98. }
  99. }