Advertisement
Guest User

Untitled

a guest
Sep 30th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. <?php
  2. namespace Backend\Modules\Asaf\Domain\Products;
  3.  
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Backend\Core\Engine\Authentication;
  6. use Common\Doctrine\Entity\Meta;
  7. use Backend\Modules\MediaLibrary\Domain\MediaGroup\MediaGroup;
  8. use Backend\Modules\MediaLibrary\Domain\MediaGroup\Type as MediaGroupType;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11.  
  12. /**
  13. *
  14. * @ORM\Table(name="asaf_catalog")
  15. * @ORM\Entity(repositoryClass="Backend\Modules\Asaf\Domain\Products\ProductRepository")
  16. * @ORM\HasLifecycleCallbacks
  17. */
  18.  
  19. class Product
  20. {
  21. /**
  22. * @var integer
  23. *
  24. * @ORM\Column(type="integer")
  25. * @ORM\Id()
  26. * @ORM\GeneratedValue()
  27. */
  28. private $id = 0;
  29.  
  30. /**
  31. * @var int
  32. *
  33. * @ORM\Column(type="integer", name="creator_user_id")
  34. */
  35. private $creatorUserId;
  36.  
  37. /**
  38. * @var string
  39. *
  40. * @ORM\Column(type="string", name="title")
  41. */
  42. private $title;
  43.  
  44. /**
  45. * @var string
  46. *
  47. * @ORM\Column(type="text", nullable=true)
  48. */
  49. private $description = '';
  50.  
  51. /**
  52. * @var string
  53. *
  54. * @ORM\Column(type="text", nullable=true)
  55. */
  56. private $text = '';
  57.  
  58. /**
  59. * @var int
  60. *
  61. * @ORM\Column(type="integer", name="editor_user_id")
  62. */
  63. private $editorUserId;
  64.  
  65. /**
  66. * @var boolean
  67. *
  68. * @ORM\Column(type="boolean", options={"default" = false})
  69. */
  70. private $active = false;
  71.  
  72. /**
  73. * @var boolean
  74. *
  75. * @ORM\Column(type="boolean")
  76. */
  77. private $onMain = false;
  78.  
  79.  
  80. /**
  81. * @var Meta
  82. *
  83. * @ORM\OneToOne(
  84. * targetEntity="Common\Doctrine\Entity\Meta",
  85. * cascade="persist",
  86. * orphanRemoval=true
  87. * )
  88. * @ORM\JoinColumn(
  89. * name="meta_id",
  90. * referencedColumnName="id",
  91. * onDelete="cascade"
  92. * )
  93. * @ORM\Column(name="meta_id", nullable=true)
  94. */
  95. private $meta;
  96.  
  97. /**
  98. * @var string
  99. *
  100. * @ORM\Column(type="string", length=255, nullable=true)
  101. */
  102. private $image = '';
  103.  
  104. /**
  105. * @var MediaGroup
  106. *
  107. * @ORM\OneToOne(
  108. * targetEntity="Backend\Modules\MediaLibrary\Domain\MediaGroup\MediaGroup",
  109. * cascade="persist",
  110. * orphanRemoval=true
  111. * )
  112. * @ORM\JoinColumn(
  113. * name="mediaGroupId",
  114. * referencedColumnName="id",
  115. * onDelete="cascade"
  116. * )
  117. */
  118. private $mediaGroup;
  119.  
  120. /**
  121. * @var Collection
  122. *
  123. * @ORM\ManyToOne(targetEntity="Backend\Modules\Asaf\Domain\Categorys\Category",mappedBy="product")
  124. */
  125. private $category;
  126.  
  127. public function __construct(){
  128. $this->mediaGroup = MediaGroup::create(MediaGroupType::fromString('image'));
  129. $this->category = new ArrayCollection();
  130. }
  131.  
  132.  
  133. /**
  134. * @return int
  135. */
  136. public function getId(): int
  137. {
  138. return $this->id;
  139. }
  140.  
  141. public function getCreatorUserId(): int
  142. {
  143. return $this->creatorUserId;
  144. }
  145.  
  146.  
  147. public function getEditorUserId(): int
  148. {
  149. return $this->editorUserId;
  150. }
  151.  
  152. /**
  153. * @return bool
  154. */
  155. public function isActive(): bool
  156. {
  157. return $this->active;
  158. }
  159.  
  160. /**
  161. * @param bool $active
  162. */
  163. public function setActive(bool $active): void
  164. {
  165. $this->active = $active;
  166. }
  167.  
  168. /**
  169. * @return Collection $category
  170. */
  171. public function getCategory()
  172. {
  173. return $this->category;
  174. }
  175.  
  176. public function setCategory(Collection $category)
  177. {
  178. $this->category = $category;
  179. }
  180.  
  181.  
  182. /**
  183. * @return bool
  184. */
  185. public function isOnMain(): bool
  186. {
  187. return $this->onMain;
  188. }
  189.  
  190. /**
  191. * @param bool $onMain
  192. */
  193. public function setOnMain(bool $onMain): void
  194. {
  195. $this->onMain = $onMain;
  196. }
  197.  
  198. /**
  199. * @return string
  200. */
  201. public function getTitle()
  202. {
  203. return (string)$this->title;
  204. }
  205.  
  206. /**
  207. * @param string $title
  208. */
  209. public function setTitle(string $title): void
  210. {
  211. $this->title = $title;
  212. }
  213.  
  214. /**
  215. * @return string
  216. */
  217. public function getDescription()
  218. {
  219. return (string)$this->description;
  220. }
  221.  
  222. /**
  223. * @param string $description
  224. */
  225. public function setDescription(string $description): void
  226. {
  227. $this->description = $description;
  228. }
  229.  
  230. /**
  231. * @return string
  232. */
  233. public function getText()
  234. {
  235. return (string)$this->text;
  236. }
  237.  
  238. /**
  239. * @return Meta
  240. */
  241. public function getMeta()
  242. {
  243. return $this->meta;
  244. }
  245.  
  246. /**
  247. * @param Meta $meta
  248. */
  249. public function setMeta(Meta $meta): void
  250. {
  251. $this->meta = $meta;
  252. }
  253.  
  254. /**
  255. * @return string
  256. */
  257. public function getImage(): string
  258. {
  259. return $this->image;
  260. }
  261.  
  262. /**
  263. * @param string $image
  264. */
  265. //public function setImage(string $image): void
  266. public function setImage($image): void
  267. {
  268. if(!$image){
  269. $image = '';
  270. }
  271. $this->image = $image;
  272. }
  273.  
  274. /**
  275. * @return MediaGroup
  276. */
  277. public function getMediaGroup()
  278. {
  279. return $this->mediaGroup;
  280. }
  281.  
  282. /**
  283. * @param MediaGroup $mediaGroup
  284. */
  285. public function setMediaGroup(MediaGroup $mediaGroup): void
  286. {
  287. $this->mediaGroup = $mediaGroup;
  288. }
  289.  
  290. /**
  291. * @param string $text
  292. */
  293. public function setText( $text): void
  294. {
  295. $this->text = $text;
  296. }
  297.  
  298. /**
  299. * @ORM\PrePersist
  300. */
  301. public function prePersist()
  302. {
  303. // $this->createdOn = $this->editedOn = new DateTime();
  304. $this->creatorUserId = $this->editorUserId = Authentication::getUser()->getUserId();
  305. }
  306.  
  307. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement