vendor/roothirsch/shop-bundle/Entity/EstimatePositionAttribute.php line 13

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\ShopBundle\Entity;
  3. use Roothirsch\CoreBundle\Entity\Traits\TimetrackedTrait;
  4. use Roothirsch\ShopBundle\Repository\EstimatePositionAttributeRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass=EstimatePositionAttributeRepository::class)
  8. * @ORM\Table(name="shop_estimate_position_attribute")
  9. */
  10. class EstimatePositionAttribute
  11. {
  12. use TimetrackedTrait;
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\ManyToOne(targetEntity=EstimatePosition::class, inversedBy="attributes")
  21. * @ORM\JoinColumn(nullable=false)
  22. */
  23. private $position;
  24. /**
  25. * @ORM\Column(type="string", length=255, nullable=true)
  26. */
  27. private $title;
  28. /**
  29. * @ORM\Column(type="string", length=255)
  30. */
  31. private $name;
  32. /**
  33. * @ORM\Column(type="text", nullable=true)
  34. */
  35. private $data;
  36. /**
  37. * @ORM\Column(type="text", nullable=true)
  38. */
  39. private $value;
  40. /**
  41. * @ORM\Column(type="string", length=255, nullable=true)
  42. */
  43. private $amount;
  44. /**
  45. * @ORM\Column(type="string", length=255, nullable=true)
  46. */
  47. private $amountFormat;
  48. /**
  49. * @ORM\Column(type="integer", nullable=true)
  50. */
  51. private $price;
  52. /**
  53. * @ORM\Column(type="integer", nullable=true)
  54. */
  55. private $total;
  56. /**
  57. * @ORM\Column(type="string", length=255, nullable=true)
  58. */
  59. private $article;
  60. public function getId(): ?int
  61. {
  62. return $this->id;
  63. }
  64. public function setId($id)
  65. {
  66. $this->id = $id;
  67. }
  68. public function getTitle(): ?string
  69. {
  70. return $this->title;
  71. }
  72. public function setTitle($title): self
  73. {
  74. $this->title = $title;
  75. return $this;
  76. }
  77. public function getName(): ?string
  78. {
  79. return $this->name;
  80. }
  81. public function setName(string $name): self
  82. {
  83. $this->name = $name;
  84. return $this;
  85. }
  86. public function getData(): ?string
  87. {
  88. return $this->data;
  89. }
  90. public function setData(?string $data): self
  91. {
  92. $this->data = $data;
  93. return $this;
  94. }
  95. public function getPosition(): ?EstimatePosition
  96. {
  97. return $this->position;
  98. }
  99. public function setPosition(?EstimatePosition $position): self
  100. {
  101. $this->position = $position;
  102. return $this;
  103. }
  104. const ZERO_VALUE = '833dd2fc-c713-11ed-afa1-0242ac120002';
  105. /**
  106. * @return mixed
  107. */
  108. public function getValue()
  109. {
  110. if ($this->value == self::ZERO_VALUE) {
  111. return 0;
  112. }
  113. return $this->value;
  114. }
  115. /**
  116. * @param mixed $value
  117. */
  118. public function setValue($value): void
  119. {
  120. $this->value = $value;
  121. }
  122. public function getAmount(): ?string
  123. {
  124. return $this->amount;
  125. }
  126. public function setAmount($amount): self
  127. {
  128. $this->amount = $amount;
  129. return $this;
  130. }
  131. public function getAmountFormat(): ?string
  132. {
  133. return $this->amountFormat;
  134. }
  135. public function setAmountFormat(?string $amountFormat): self
  136. {
  137. $this->amountFormat = $amountFormat;
  138. return $this;
  139. }
  140. public function getPrice(): ?int
  141. {
  142. return $this->price;
  143. }
  144. public function setPrice(?int $price): self
  145. {
  146. $this->price = $price;
  147. return $this;
  148. }
  149. public function getTotal(): ?int
  150. {
  151. return $this->total;
  152. }
  153. public function setTotal(?int $total): self
  154. {
  155. $this->total = $total;
  156. return $this;
  157. }
  158. public function getArticle(): ?string
  159. {
  160. return $this->article;
  161. }
  162. public function setArticle(?string $article): self
  163. {
  164. $this->article = $article;
  165. return $this;
  166. }
  167. public function convertToTemplatePositionAttribute() {
  168. $attribute = new PositionTemplateAttribute();
  169. $attribute->setTitle($this->getTitle());
  170. $attribute->setName($this->getName());
  171. $attribute->setData($this->getData());
  172. $attribute->setValue($this->getValue());
  173. $attribute->setAmount($this->getAmount());
  174. $attribute->setAmountFormat($this->getAmountFormat());
  175. $attribute->setPrice($this->getPrice());
  176. $attribute->setTotal($this->getTotal());
  177. $attribute->setArticle($this->getArticle());
  178. return $attribute;
  179. }
  180. }