src/ProductBundle/Entity/ProductHasOccasion.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\ProductBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5. * @ORM\HasLifecycleCallbacks
  6. * @ORM\Table("product_occasion")
  7. * @ORM\Entity(repositoryClass="App\ProductBundle\Repository\ProductHasOccasionRepository")
  8. */
  9. class ProductHasOccasion
  10. {
  11. /**
  12. * @ORM\Id
  13. * @ORM\ManyToOne(targetEntity="Occasion", inversedBy="productHasOccasions")
  14. */
  15. private ?Occasion $occasion = null;
  16. /**
  17. * @ORM\Id
  18. * @ORM\ManyToOne(targetEntity="Product", inversedBy="productHasOccasions")
  19. */
  20. private ?Product $product;
  21. /**
  22. * @ORM\Column(type="datetime")
  23. */
  24. private ?\DateTimeInterface $created = null;
  25. /**
  26. * Now we tell doctrine that before we persist or update we call the updatedTimestamps() function.
  27. *
  28. * @ORM\PrePersist
  29. * @ORM\PreUpdate
  30. */
  31. public function updatedTimestamps(): void
  32. {
  33. if ($this->getCreated() == null) {
  34. $this->setCreated(new \DateTime(date('Y-m-d H:i:s')));
  35. }
  36. }
  37. public function __clone()
  38. {
  39. if ($this->product) {
  40. $this->product = null;
  41. }
  42. }
  43. public function getCreated(): ?\DateTimeInterface
  44. {
  45. return $this->created;
  46. }
  47. public function setCreated(\DateTimeInterface $created): self
  48. {
  49. $this->created = $created;
  50. return $this;
  51. }
  52. public function getOccasion(): ?Occasion
  53. {
  54. return $this->occasion;
  55. }
  56. public function setOccasion(?Occasion $occasion): self
  57. {
  58. $this->occasion = $occasion;
  59. return $this;
  60. }
  61. public function getProduct(): ?Product
  62. {
  63. return $this->product;
  64. }
  65. public function setProduct(?Product $product): self
  66. {
  67. $this->product = $product;
  68. return $this;
  69. }
  70. }