src/Entity/ActionLog.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActionLogRepository;
  4. use DateTime;
  5. use DateTimeInterface;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. use JMS\Serializer\Annotation\SerializedName;
  11. /**
  12. * @ORM\Entity(repositoryClass=ActionLogRepository::class)
  13. *
  14. * @Serializer\ExclusionPolicy("ALL")
  15. */
  16. class ActionLog
  17. {
  18. public const CONTEXT_DYNAMIC_IMPORT = 'import_dynamic';
  19. public const CONTEXT_POINT_IMPORT = 'import_point_transaction';
  20. public const CONTEXT_POINT_MANUAL = 'manual_point_transaction';
  21. public const CONTEXT_PLATFORM_YAML_UPDATE = 'update_platform_yaml';
  22. public const CONTEXT_USER_UPDATE = 'update_user';
  23. public const CONTEXT_ENTITY_UPDATE = 'update_entity';
  24. public const LOG_LEVELS = [
  25. 2 => 'INFO',
  26. 1 => 'NOTICE',
  27. ];
  28. /**
  29. * @ORM\Id
  30. * @ORM\GeneratedValue
  31. * @ORM\Column(type="integer")
  32. *
  33. * @Expose
  34. * @Groups ({
  35. * "actionLog:id",
  36. * "actionLog",
  37. * })
  38. */
  39. private $id;
  40. /**
  41. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="actionLogs")
  42. * @ORM\JoinColumn(nullable=false)
  43. *
  44. * @Expose
  45. * @Groups ({
  46. * "actionLog:user",
  47. * "actionLog",
  48. * })
  49. */
  50. private $user;
  51. /**
  52. * @ORM\Column(name="message", type="text")
  53. *
  54. * @Expose
  55. * @Groups ({
  56. * "actionLog:message",
  57. * "actionLog",
  58. * })
  59. */
  60. private $message;
  61. /**
  62. * @ORM\Column(name="context", type="text")
  63. *
  64. * @Expose
  65. * @Groups ({
  66. * "actionLog:context",
  67. * "actionLog",
  68. * })
  69. */
  70. private $context;
  71. /**
  72. * @ORM\Column(name="level", type="smallint")
  73. *
  74. * @Expose
  75. * @Groups ({
  76. * "actionLog:level",
  77. * "actionLog",
  78. * })
  79. */
  80. private $level;
  81. /**
  82. * @ORM\Column(name="level_name", type="string", length=50)
  83. *
  84. * @Expose
  85. * @Groups ({
  86. * "actionLog:levelName",
  87. * "actionLog",
  88. * })
  89. */
  90. private $levelName;
  91. /**
  92. * @ORM\Column(name="extra", type="text")
  93. */
  94. private $extra;
  95. /**
  96. * @ORM\Column(name="created_at", type="datetime")
  97. *
  98. * @Expose
  99. * @Groups ({
  100. * "actionLog:createdAt",
  101. * "actionLog",
  102. * })
  103. */
  104. private $createdAt;
  105. /**
  106. * @ORM\PrePersist
  107. */
  108. public function onPrePersist()
  109. {
  110. $this->createdAt = new DateTime();
  111. }
  112. public function getId(): ?int
  113. {
  114. return $this->id;
  115. }
  116. public function getMessage(): ?string
  117. {
  118. return $this->message;
  119. }
  120. public function setMessage( string $message ): self
  121. {
  122. $this->message = $message;
  123. return $this;
  124. }
  125. public function getContext(): string
  126. {
  127. return $this->context;
  128. }
  129. public function setContext( string $context ): self
  130. {
  131. $this->context = $context;
  132. return $this;
  133. }
  134. public function getLevel(): ?int
  135. {
  136. return $this->level;
  137. }
  138. public function setLevel( int $level ): self
  139. {
  140. $this->level = $level;
  141. return $this;
  142. }
  143. public function getLevelName(): ?string
  144. {
  145. return $this->levelName;
  146. }
  147. public function setLevelName( string $levelName ): self
  148. {
  149. $this->levelName = $levelName;
  150. return $this;
  151. }
  152. public function getExtra(): ?string
  153. {
  154. return $this->extra;
  155. }
  156. /**
  157. * @return array
  158. *
  159. * @Serializer\VirtualProperty()
  160. * @SerializedName ("extra")
  161. *
  162. * @Expose
  163. * @Groups ({
  164. * "actionLog:extra",
  165. * "actionLog",
  166. * })
  167. */
  168. public function getExtraArray(): array
  169. {
  170. return json_decode( $this->extra, TRUE );
  171. }
  172. public function setExtra( string $extra ): self
  173. {
  174. $this->extra = $extra;
  175. return $this;
  176. }
  177. public function getCreatedAt(): ?DateTimeInterface
  178. {
  179. return $this->createdAt;
  180. }
  181. public function setCreatedAt( DateTimeInterface $createdAt ): self
  182. {
  183. $this->createdAt = $createdAt;
  184. return $this;
  185. }
  186. public function getUser(): ?User
  187. {
  188. return $this->user;
  189. }
  190. public function setUser( ?User $user ): self
  191. {
  192. $this->user = $user;
  193. return $this;
  194. }
  195. }