src/Entity/Payment.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use App\Entity\Behaviors\TranslatableTrait;
  10. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  11. /**
  12. * @ORM\Entity(repositoryClass="App\Repository\PaymentRepository")
  13. * @ORM\EntityListeners({"App\Listener\EntityListener"})
  14. * @Vich\Uploadable()
  15. */
  16. class Payment implements TranslatableInterface
  17. {
  18. use TranslatableTrait;
  19. /**
  20. * @ORM\Id()
  21. * @ORM\GeneratedValue()
  22. * @ORM\Column(type="integer")
  23. */
  24. private $id;
  25. /**
  26. * @Vich\UploadableField(mapping="transport_logo", fileNameProperty="image")
  27. * @Assert\Image(mimeTypes={"image/png", "image/jpeg", "image/jpg", "image/gif"})
  28. * @var File|null
  29. */
  30. private $imageFile;
  31. /**
  32. * @ORM\Column(type="string", length=199, nullable=true)
  33. */
  34. private $image;
  35. /**
  36. * @ORM\Column(type="integer", nullable=false)
  37. */
  38. private $type;
  39. /**
  40. * @ORM\Column(type="integer", nullable=false)
  41. */
  42. private $priority = 9;
  43. /**
  44. * @ORM\Column(type="boolean")
  45. */
  46. private $isActive = true;
  47. /**
  48. * @ORM\Column(type="string", length=190)
  49. */
  50. private $code;
  51. /**
  52. * @ORM\Column(type="datetime")
  53. */
  54. private $createts;
  55. /**
  56. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  57. * @ORM\JoinColumn(nullable=false)
  58. */
  59. private $createUser;
  60. /**
  61. * @ORM\Column(type="datetime", nullable=true)
  62. */
  63. private $editts;
  64. /**
  65. * @ORM\ManyToOne(targetEntity="App\Entity\User")
  66. */
  67. private $editUser;
  68. /**
  69. * @ORM\ManyToMany(targetEntity="App\Entity\Transport", mappedBy="payments")
  70. */
  71. private $transports;
  72. /**
  73. * @ORM\OneToMany(targetEntity="App\Entity\Pricelist", mappedBy="payment", cascade={"persist", "remove"}, orphanRemoval=true, indexBy="currency")
  74. */
  75. private $pricelists;
  76. /**
  77. * @Vich\UploadableField(mapping="cert_files", fileNameProperty="privateKey")
  78. * @var File|null
  79. */
  80. private $privateKeyFile;
  81. /**
  82. * @ORM\Column(type="string", length=199, nullable=true)
  83. */
  84. private $privateKey;
  85. /**
  86. * @ORM\Column(type="string", length=199, nullable=true)
  87. */
  88. private $onlineType;
  89. /**
  90. * @ORM\Column(type="string", length=199, nullable=true)
  91. */
  92. private $privateKeyPassword;
  93. /**
  94. * @ORM\Column(type="string", length=199, nullable=true)
  95. */
  96. private $merchantNumber;
  97. /**
  98. * @Vich\UploadableField(mapping="cert_files", fileNameProperty="publicKey")
  99. * @var File|null
  100. */
  101. private $publicKeyFile;
  102. /**
  103. * @ORM\Column(type="string", length=199, nullable=true)
  104. */
  105. private $publicKey;
  106. /**
  107. * @ORM\Column(type="boolean")
  108. */
  109. private $production = false;
  110. public function __construct()
  111. {
  112. $this->transports = new ArrayCollection();
  113. $this->pricelists = new ArrayCollection();
  114. }
  115. public function checkPricelists($currencies){
  116. $diff = array_diff($currencies,array_keys($this->getPricelists()->toArray()));
  117. if(count($diff)>0){
  118. foreach ($diff as $curr){
  119. $price = new Pricelist($curr);
  120. $this->addPricelist($price);
  121. }
  122. }
  123. }
  124. public function getId(): ?int
  125. {
  126. return $this->id;
  127. }
  128. public function getCode(): ?string
  129. {
  130. return $this->code;
  131. }
  132. public function setCode(string $code): self
  133. {
  134. $this->code = $code;
  135. return $this;
  136. }
  137. public function getCreatets(): ?\DateTimeInterface
  138. {
  139. return $this->createts;
  140. }
  141. public function setCreatets(\DateTimeInterface $createts): self
  142. {
  143. $this->createts = $createts;
  144. return $this;
  145. }
  146. public function getCreateUser(): ?User
  147. {
  148. return $this->createUser;
  149. }
  150. public function setCreateUser(?User $createUser): self
  151. {
  152. $this->createUser = $createUser;
  153. return $this;
  154. }
  155. public function getEditts(): ?\DateTimeInterface
  156. {
  157. return $this->editts;
  158. }
  159. public function setEditts(?\DateTimeInterface $editts): self
  160. {
  161. $this->editts = $editts;
  162. return $this;
  163. }
  164. public function getEditUser(): ?User
  165. {
  166. return $this->editUser;
  167. }
  168. public function setEditUser(?User $editUser): self
  169. {
  170. $this->editUser = $editUser;
  171. return $this;
  172. }
  173. public function getImage(): ?string
  174. {
  175. return $this->image;
  176. }
  177. public function setImage(?string $image): self
  178. {
  179. $this->image = $image;
  180. return $this;
  181. }
  182. public function getIsActive(): ?bool
  183. {
  184. return $this->isActive;
  185. }
  186. public function setIsActive(bool $isActive): self
  187. {
  188. $this->isActive = $isActive;
  189. return $this;
  190. }
  191. /**
  192. * Get ImageFile
  193. *
  194. * @return null|File
  195. */
  196. public function getImageFile()
  197. {
  198. return $this->imageFile;
  199. }
  200. /**
  201. * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  202. */
  203. public function setImageFile(?File $imageFile = null): void
  204. {
  205. $this->imageFile = $imageFile;
  206. if (null !== $imageFile) {
  207. $this->editts = new \DateTime();
  208. }
  209. }
  210. /**
  211. * @return Collection|Transport[]
  212. */
  213. public function getTransports(): Collection
  214. {
  215. return $this->transports;
  216. }
  217. public function addTransport(Transport $transport): self
  218. {
  219. if (!$this->transports->contains($transport)) {
  220. $this->transports[] = $transport;
  221. }
  222. return $this;
  223. }
  224. public function removeTransport(Transport $transport): self
  225. {
  226. if ($this->transports->contains($transport)) {
  227. $this->transports->removeElement($transport);
  228. }
  229. return $this;
  230. }
  231. /**
  232. * @return Collection|Pricelist[]
  233. */
  234. public function getPricelists(): Collection
  235. {
  236. return $this->pricelists;
  237. }
  238. public function addPricelist(Pricelist $pricelist): self
  239. {
  240. if (!$this->pricelists->contains($pricelist)) {
  241. $this->pricelists[] = $pricelist;
  242. $pricelist->setPayment($this);
  243. }
  244. return $this;
  245. }
  246. public function removePricelist(Pricelist $pricelist): self
  247. {
  248. if ($this->pricelists->contains($pricelist)) {
  249. $this->pricelists->removeElement($pricelist);
  250. // set the owning side to null (unless already changed)
  251. if ($pricelist->getPayment() === $this) {
  252. $pricelist->setPayment(null);
  253. }
  254. }
  255. return $this;
  256. }
  257. public function __call($method, $arguments)
  258. {
  259. $ret = $this->proxyCurrentLocaleTranslation($method, $arguments);
  260. if(empty($ret)) {
  261. $ret = call_user_func_array( [ $this->translate( \Locale::getDefault() ), $method ], $arguments );
  262. }
  263. return $ret;
  264. }
  265. /**
  266. * Get Type
  267. *
  268. * @return mixed
  269. */
  270. public function getType()
  271. {
  272. return $this->type;
  273. }
  274. /**
  275. * Set Type
  276. *
  277. * @param mixed $type
  278. */
  279. public function setType( $type )
  280. {
  281. $this->type = $type;
  282. }
  283. /**
  284. * Get getPrivateKeyFile
  285. *
  286. * @return null|File
  287. */
  288. public function getPrivateKeyFile()
  289. {
  290. return $this->privateKeyFile;
  291. }
  292. /**
  293. * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $privateKeyFile
  294. */
  295. public function setPrivateKeyFile(?File $privateKeyFile = null): void
  296. {
  297. $this->privateKeyFile = $privateKeyFile;
  298. if (null !== $privateKeyFile) {
  299. $this->editts = new \DateTime();
  300. }
  301. }
  302. /**
  303. * Get PrivateKey
  304. *
  305. * @return mixed
  306. */
  307. public function getPrivateKey()
  308. {
  309. return $this->privateKey;
  310. }
  311. /**
  312. * Set PrivateKey
  313. *
  314. * @param mixed $privateKey
  315. */
  316. public function setPrivateKey( $privateKey )
  317. {
  318. $this->privateKey = $privateKey;
  319. }
  320. /**
  321. * Get PublicKey
  322. *
  323. * @return mixed
  324. */
  325. public function getPublicKey()
  326. {
  327. return $this->publicKey;
  328. }
  329. /**
  330. * Set PublicKey
  331. *
  332. * @param mixed $publicKey
  333. */
  334. public function setPublicKey( $publicKey )
  335. {
  336. $this->publicKey = $publicKey;
  337. }
  338. /**
  339. * Get getPublicKeyFile
  340. *
  341. * @return null|File
  342. */
  343. public function getPublicKeyFile()
  344. {
  345. return $this->publicKeyFile;
  346. }
  347. /**
  348. * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $publicKeyFile
  349. */
  350. public function setPublicKeyFile(?File $publicKeyFile = null): void
  351. {
  352. $this->publicKeyFile = $publicKeyFile;
  353. if (null !== $publicKeyFile) {
  354. $this->editts = new \DateTime();
  355. }
  356. }
  357. /**
  358. * Get PrivateKeyPassword
  359. *
  360. * @return mixed
  361. */
  362. public function getPrivateKeyPassword()
  363. {
  364. return $this->privateKeyPassword;
  365. }
  366. /**
  367. * Set PrivateKeyPassword
  368. *
  369. * @param mixed $privateKeyPassword
  370. */
  371. public function setPrivateKeyPassword( $privateKeyPassword )
  372. {
  373. $this->privateKeyPassword = $privateKeyPassword;
  374. }
  375. /**
  376. * Get MerchantNumber
  377. *
  378. * @return mixed
  379. */
  380. public function getMerchantNumber()
  381. {
  382. return $this->merchantNumber;
  383. }
  384. /**
  385. * Set MerchantNumber
  386. *
  387. * @param mixed $merchantNumber
  388. */
  389. public function setMerchantNumber( $merchantNumber )
  390. {
  391. $this->merchantNumber = $merchantNumber;
  392. }
  393. /**
  394. * Get OnlineType
  395. *
  396. * @return mixed
  397. */
  398. public function getOnlineType()
  399. {
  400. return $this->onlineType;
  401. }
  402. /**
  403. * Set OnlineType
  404. *
  405. * @param mixed $onlineType
  406. */
  407. public function setOnlineType( $onlineType )
  408. {
  409. $this->onlineType = $onlineType;
  410. }
  411. /**
  412. * Get Production
  413. *
  414. * @return mixed
  415. */
  416. public function getProduction()
  417. {
  418. return $this->production;
  419. }
  420. /**
  421. * Set Production
  422. *
  423. * @param mixed $production
  424. */
  425. public function setProduction( $production )
  426. {
  427. $this->production = $production;
  428. }
  429. /**
  430. * @return int
  431. */
  432. public function getPriority(): int
  433. {
  434. return $this->priority;
  435. }
  436. /**
  437. * @param int $priority
  438. */
  439. public function setPriority(int $priority): void
  440. {
  441. $this->priority = $priority;
  442. }
  443. }