src/Entity/ActionLog.php line 20

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