<?php
namespace App\Entity;
use App\Repository\ActionLogRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;
/**
* @ORM\Entity(repositoryClass=ActionLogRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
*/
class ActionLog
{
public const CONTEXT_DYNAMIC_IMPORT = 'import_dynamic';
public const CONTEXT_POINT_IMPORT = 'import_point_transaction';
public const CONTEXT_POINT_MANUAL = 'manual_point_transaction';
public const CONTEXT_PLATFORM_YAML_UPDATE = 'update_platform_yaml';
public const CONTEXT_USER_UPDATE = 'update_user';
public const CONTEXT_ENTITY_UPDATE = 'update_entity';
public const LOG_LEVELS = [
2 => 'INFO',
1 => 'NOTICE',
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups ({
* "actionLog:id",
* "actionLog",
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="actionLogs")
* @ORM\JoinColumn(nullable=false)
*
* @Expose
* @Groups ({
* "actionLog:user",
* "actionLog",
* })
*/
private $user;
/**
* @ORM\Column(name="message", type="text")
*
* @Expose
* @Groups ({
* "actionLog:message",
* "actionLog",
* })
*/
private $message;
/**
* @ORM\Column(name="context", type="text")
*
* @Expose
* @Groups ({
* "actionLog:context",
* "actionLog",
* })
*/
private $context;
/**
* @ORM\Column(name="level", type="smallint")
*
* @Expose
* @Groups ({
* "actionLog:level",
* "actionLog",
* })
*/
private $level;
/**
* @ORM\Column(name="level_name", type="string", length=50)
*
* @Expose
* @Groups ({
* "actionLog:levelName",
* "actionLog",
* })
*/
private $levelName;
/**
* @ORM\Column(name="extra", type="text")
*/
private $extra;
/**
* @ORM\Column(name="created_at", type="datetime")
*
* @Expose
* @Groups ({
* "actionLog:createdAt",
* "actionLog",
* })
*/
private $createdAt;
/**
* @ORM\PrePersist
*/
public function onPrePersist()
{
$this->createdAt = new DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setMessage( string $message ): self
{
$this->message = $message;
return $this;
}
public function getContext(): string
{
return $this->context;
}
public function setContext( string $context ): self
{
$this->context = $context;
return $this;
}
public function getLevel(): ?int
{
return $this->level;
}
public function setLevel( int $level ): self
{
$this->level = $level;
return $this;
}
public function getLevelName(): ?string
{
return $this->levelName;
}
public function setLevelName( string $levelName ): self
{
$this->levelName = $levelName;
return $this;
}
public function getExtra(): ?string
{
return $this->extra;
}
/**
* @return array
*
* @Serializer\VirtualProperty()
* @SerializedName ("extra")
*
* @Expose
* @Groups ({
* "actionLog:extra",
* "actionLog",
* })
*/
public function getExtraArray(): array
{
return json_decode( $this->extra, TRUE );
}
public function setExtra( string $extra ): self
{
$this->extra = $extra;
return $this;
}
public function getCreatedAt(): ?DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt( DateTimeInterface $createdAt ): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser( ?User $user ): self
{
$this->user = $user;
return $this;
}
}