105 行
2.4KB

  1. <?php
  2. namespace Lc\ShopBundle\Model;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. use Lc\ShopBundle\Context\UserInterface;
  6. /**
  7. * @ORM\MappedSuperclass
  8. */
  9. abstract class AbstractEntity
  10. {
  11. protected $errors;
  12. /**
  13. * @ORM\Column(type="datetime")
  14. * @Gedmo\Timestampable(on="create")
  15. */
  16. protected $createdAt;
  17. /**
  18. * @ORM\Column(type="datetime")
  19. * @Gedmo\Timestampable(on="update")
  20. */
  21. protected $updatedAt;
  22. /**
  23. * @Gedmo\Blameable(on="create")
  24. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
  25. * @ORM\JoinColumn(nullable=false)
  26. */
  27. protected $createdBy;
  28. /**
  29. * @Gedmo\Blameable(on="update")
  30. * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
  31. * @ORM\JoinColumn(nullable=false)
  32. */
  33. protected $updatedBy;
  34. public function addError($message, $domain = 'lcshop', $params){
  35. $this->errors[] = array(
  36. 'message'=> $message,
  37. 'domain'=> $domain,
  38. 'params'=>$params
  39. );
  40. return $this->errors;
  41. }
  42. public function getErrors(){
  43. return $this->errors;
  44. }
  45. public function getCreatedAt(): ?\DateTimeInterface
  46. {
  47. return $this->createdAt;
  48. }
  49. public function setCreatedAt(\DateTimeInterface $createdAt): self
  50. {
  51. $this->createdAt = $createdAt;
  52. return $this;
  53. }
  54. public function getUpdatedAt(): ?\DateTimeInterface
  55. {
  56. return $this->updatedAt;
  57. }
  58. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  59. {
  60. $this->updatedAt = $updatedAt;
  61. return $this;
  62. }
  63. public function getCreatedBy(): ?UserInterface
  64. {
  65. return $this->createdBy;
  66. }
  67. public function setCreatedBy(?UserInterface $createdBy): self
  68. {
  69. $this->createdBy = $createdBy;
  70. return $this;
  71. }
  72. public function getUpdatedBy(): ?UserInterface
  73. {
  74. return $this->updatedBy;
  75. }
  76. public function setUpdatedBy(?UserInterface $updatedBy): self
  77. {
  78. $this->updatedBy = $updatedBy;
  79. return $this;
  80. }
  81. }