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

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\ShopBundle\Entity;
  3. use Roothirsch\CoreBundle\Entity\Traits\TimetrackedTrait;
  4. use App\Repository\Shop\Entity\OrderPositionAttributeRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass=OrderPositionAttributeRepository::class)
  8. * @ORM\Table(name="shop_order_position_attribute")
  9. */
  10. class OrderPositionAttribute
  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=OrderPosition::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. /**
  65. * @return mixed
  66. */
  67. public function getPosition()
  68. {
  69. return $this->position;
  70. }
  71. /**
  72. * @param mixed $position
  73. */
  74. public function setPosition($position): void
  75. {
  76. $this->position = $position;
  77. }
  78. /**
  79. * @return mixed
  80. */
  81. public function getTitle()
  82. {
  83. return $this->title;
  84. }
  85. /**
  86. * @param mixed $title
  87. */
  88. public function setTitle($title): void
  89. {
  90. $this->title = $title;
  91. }
  92. /**
  93. * @return mixed
  94. */
  95. public function getName()
  96. {
  97. return $this->name;
  98. }
  99. /**
  100. * @param mixed $name
  101. */
  102. public function setName($name): void
  103. {
  104. $this->name = $name;
  105. }
  106. /**
  107. * @return mixed
  108. */
  109. public function getData()
  110. {
  111. return $this->data;
  112. }
  113. /**
  114. * @param mixed $data
  115. */
  116. public function setData($data): void
  117. {
  118. $this->data = $data;
  119. }
  120. const ZERO_VALUE = '833dd2fc-c713-11ed-afa1-0242ac120002';
  121. /**
  122. * @return mixed
  123. */
  124. public function getValue(): string
  125. {
  126. if ($this->value == self::ZERO_VALUE) {
  127. return '0';
  128. }
  129. return strval($this->value);
  130. }
  131. /**
  132. * @param mixed $value
  133. */
  134. public function setValue($value): void
  135. {
  136. $this->value = $value;
  137. }
  138. /**
  139. * @return mixed
  140. */
  141. public function getAmount()
  142. {
  143. return $this->amount;
  144. }
  145. /**
  146. * @param mixed $amount
  147. */
  148. public function setAmount($amount): void
  149. {
  150. $this->amount = $amount;
  151. }
  152. /**
  153. * @return mixed
  154. */
  155. public function getAmountFormat()
  156. {
  157. return $this->amountFormat;
  158. }
  159. /**
  160. * @param mixed $amountFormat
  161. */
  162. public function setAmountFormat($amountFormat): void
  163. {
  164. $this->amountFormat = $amountFormat;
  165. }
  166. /**
  167. * @return mixed
  168. */
  169. public function getPrice()
  170. {
  171. return $this->price;
  172. }
  173. /**
  174. * @param mixed $price
  175. */
  176. public function setPrice($price): void
  177. {
  178. $this->price = $price;
  179. }
  180. /**
  181. * @return mixed
  182. */
  183. public function getTotal()
  184. {
  185. return $this->total;
  186. }
  187. /**
  188. * @param mixed $total
  189. */
  190. public function setTotal($total): void
  191. {
  192. $this->total = $total;
  193. }
  194. /**
  195. * @return mixed
  196. */
  197. public function getArticle()
  198. {
  199. return $this->article;
  200. }
  201. /**
  202. * @param mixed $article
  203. */
  204. public function setArticle($article): void
  205. {
  206. $this->article = $article;
  207. }
  208. public function convertToTemplatePositionAttribute() {
  209. $attribute = new PositionTemplateAttribute();
  210. $attribute->setTitle($this->getTitle());
  211. $attribute->setName($this->getName());
  212. $attribute->setData($this->getData());
  213. $attribute->setValue($this->getValue());
  214. $attribute->setAmount($this->getAmount());
  215. $attribute->setAmountFormat($this->getAmountFormat());
  216. $attribute->setPrice($this->getPrice());
  217. $attribute->setTotal($this->getTotal());
  218. $attribute->setArticle($this->getArticle());
  219. return $attribute;
  220. }
  221. }