src/Entity/ECommerce/Synonym.php line 207

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ECommerce;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Entity\ECommerce\Traits\DatesTrait;
  5. /**
  6. * Synonym
  7. *
  8. * @ORM\Table(
  9. * name="product_synonym",
  10. * indexes={
  11. * @ORM\Index(name="synonym_title", columns={"title"})
  12. * }
  13. * )
  14. * @ORM\Entity(repositoryClass="App\Repository\ECommerce\SynonymRepository")
  15. * @ORM\Cache(usage="READ_ONLY", region="public")
  16. */
  17. class Synonym
  18. {
  19. const GREEN = 0;
  20. const BLUE = 1;
  21. const ORANGE = 2;
  22. const RED = 3;
  23. const CATEGORIES = [
  24. 'full' => self::GREEN,
  25. 'partial' => self::BLUE,
  26. 'fair' => self::ORANGE,
  27. 'poor' => self::RED,
  28. ];
  29. /**
  30. * @var int
  31. *
  32. * @ORM\Column(name="id", type="integer")
  33. * @ORM\Id
  34. * @ORM\GeneratedValue(strategy="AUTO")
  35. */
  36. private $id;
  37. /**
  38. * @var string
  39. *
  40. * @ORM\Column(name="title", type="string", length=255)
  41. */
  42. private $title;
  43. /**
  44. * @var int
  45. *
  46. * @ORM\Column(name="category", type="smallint")
  47. */
  48. private $category = self::RED;
  49. /**
  50. * @var string
  51. *
  52. * @ORM\Column(name="manufacturer", type="string", length=30)
  53. */
  54. private $manufacturer;
  55. /**
  56. * @var string
  57. *
  58. * @ORM\Column(name="description", type="string", length=255, nullable=true)
  59. */
  60. private $description;
  61. /**
  62. * @var SynonymProduct
  63. *
  64. * @ORM\ManyToOne(targetEntity="App\Entity\ECommerce\SynonymProduct", inversedBy="synonyms")
  65. * @ORM\JoinColumn(name="synonym_product", referencedColumnName="id")
  66. */
  67. private $synonymProduct;
  68. use DatesTrait {
  69. DatesTrait::__construct as __DT_Construct;
  70. }
  71. /**
  72. * Synonym constructor.
  73. */
  74. public function __construct()
  75. {
  76. $this->__DT_Construct();
  77. $this->createdAt = new \DateTime();
  78. }
  79. /**
  80. * Get id
  81. *
  82. * @return int
  83. */
  84. public function getId()
  85. {
  86. return $this->id;
  87. }
  88. /**
  89. * Set title
  90. *
  91. * @param string $title
  92. */
  93. public function setTitle($title): static
  94. {
  95. $this->title = $title;
  96. return $this;
  97. }
  98. /**
  99. * Get title
  100. *
  101. * @return string
  102. */
  103. public function getTitle()
  104. {
  105. return $this->title;
  106. }
  107. /**
  108. * Set category
  109. *
  110. * @param integer $category
  111. */
  112. public function setCategory($category): static
  113. {
  114. $this->category = $category;
  115. return $this;
  116. }
  117. /**
  118. * Get category
  119. */
  120. public function getCategory(): int
  121. {
  122. return $this->category;
  123. }
  124. /**
  125. * Get category name
  126. */
  127. public function getCategoryName(): string
  128. {
  129. $categories = array_flip(self::CATEGORIES);
  130. return $categories[$this->category];
  131. }
  132. public function isPartial(): bool
  133. {
  134. return $this->category === self::BLUE;
  135. }
  136. /**
  137. * Set manufacturer
  138. *
  139. *
  140. */
  141. public function setManufacturer(string $manufacturer = ''): static
  142. {
  143. $this->manufacturer = $manufacturer;
  144. return $this;
  145. }
  146. /**
  147. * Get manufacturer
  148. */
  149. public function getManufacturer(): string
  150. {
  151. return (string)$this->manufacturer;
  152. }
  153. /**
  154. * Set description
  155. *
  156. * @param string $description
  157. */
  158. public function setDescription($description): static
  159. {
  160. $this->description = $description;
  161. return $this;
  162. }
  163. /**
  164. * Get description
  165. *
  166. * @return string
  167. */
  168. public function getDescription()
  169. {
  170. return $this->description;
  171. }
  172. /**
  173. * Set synonymProduct
  174. *
  175. *
  176. */
  177. public function setSynonymProduct(SynonymProduct $synonymProduct = null): static
  178. {
  179. $this->synonymProduct = $synonymProduct;
  180. return $this;
  181. }
  182. /**
  183. * Get synonymProduct
  184. *
  185. * @return SynonymProduct
  186. */
  187. public function getSynonymProduct()
  188. {
  189. return $this->synonymProduct;
  190. }
  191. }