src/Entity/Log/LogInteraction.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Log;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * LogInteraction
  9.  *
  10.  * @ORM\Table(name="log_interaction", indexes={@ORM\Index(name="IDX_USERNAME", columns={"username"})})
  11.  * @ORM\Entity(repositoryClass="App\Repository\Log\LogInteractionRepository")
  12.  */
  13. class LogInteraction
  14. {
  15.     public static $LIST 'LIST';
  16.     public static $UPDATE 'UPDATE';
  17.     public static $CREATE 'CREATE';
  18.     public static $DELETE 'DELETE';
  19.     public static $LOGIN 'LOGIN';
  20.     public static $LOGOUT 'LOGOUT';
  21.     public static $SOAP 'SOAP';
  22.     /**
  23.      * @var integer|null
  24.      *
  25.      * @ORM\Column(name="id", type="integer")
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue
  28.      */
  29.     private $id;
  30.     /**
  31.      * @var integer|null
  32.      *
  33.      * @ORM\Column(name="user_id", type="integer", nullable=true)
  34.      */
  35.     private $userId;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="username", type="string", length=255, nullable=true)
  40.      */
  41.     private $username;
  42.     /**
  43.      * @var string
  44.      *
  45.      * @ORM\Column(name="action", type="string", length=255)
  46.      */
  47.     private $action;
  48.     /**
  49.      * @var string|null
  50.      *
  51.      * @ORM\Column(name="message", type="text", nullable=true)
  52.      * @Assert\Length(
  53.      *      max = 4000,
  54.      *      maxMessage = "The field cannot be longer than {{ limit }} characters"
  55.      * )
  56.      */
  57.     private $message;
  58.     /**
  59.      * @var string|null
  60.      *
  61.      * @ORM\Column(name="error_message", type="text", nullable=true)
  62.      * @Assert\Length(
  63.      *      max = 4000,
  64.      *      maxMessage = "The field cannot be longer than {{ limit }} characters"
  65.      * )
  66.      */
  67.     private $errorMessage;
  68.     /**
  69.      * @var string|null
  70.      *
  71.      * @ORM\Column(name="stack_trace", type="text", nullable=true)
  72.      */
  73.     private $stackTrace;
  74.     /**
  75.      * @var string|null
  76.      *
  77.      * @ORM\Column(name="parameters", type="text", nullable=true)
  78.      * @Assert\Length(
  79.      *      max = 4000,
  80.      *      maxMessage = "The field cannot be longer than {{ limit }} characters"
  81.      * )
  82.      */
  83.     private $parameters;
  84.     /**
  85.      * @var string
  86.      *
  87.      * @ORM\Column(name="controller", type="string", length=255)
  88.      */
  89.     private $controller;
  90.     /**
  91.      * @var string
  92.      *
  93.      * @ORM\Column(name="aplication", type="string", length=255)
  94.      */
  95.     private $aplication;
  96.     /**
  97.      * @var string
  98.      *
  99.      * @ORM\Column(name="client_ip", type="string", length=255)
  100.      */
  101.     private $clientIp;
  102.     /**
  103.      * @var string
  104.      *
  105.      * @ORM\Column(name="request_uri", type="text", nullable=true)
  106.      */
  107.     private $requestUri;
  108.     /**
  109.      * @var string
  110.      *
  111.      * @ORM\Column(name="port", type="string", length=255, nullable=true)
  112.      */
  113.     private $port;
  114.     /**
  115.      * @var string
  116.      *
  117.      * @ORM\Column(name="method", type="string", length=255, nullable=true)
  118.      */
  119.     private $method;
  120.     /**
  121.      * @var DateTime $createdAt
  122.      *
  123.      * @Gedmo\Timestampable(on="create")
  124.      * @ORM\Column(type="datetime")
  125.      */
  126.     private $createdAt;
  127.     /**
  128.      * @return int|null
  129.      */
  130.     public function getId(): ?int
  131.     {
  132.         return $this->id;
  133.     }
  134.     /**
  135.      * @return int|null
  136.      */
  137.     public function getUserId(): ?int
  138.     {
  139.         return $this->userId;
  140.     }
  141.     /**
  142.      * @param int|null $userId
  143.      */
  144.     public function setUserId(?int $userId): void
  145.     {
  146.         $this->userId $userId;
  147.     }
  148.     /**
  149.      * @return string|null
  150.      */
  151.     public function getUsername(): ?string
  152.     {
  153.         return $this->username;
  154.     }
  155.     /**
  156.      * @param string|null $username
  157.      */
  158.     public function setUsername(?string $username): void
  159.     {
  160.         $this->username $username;
  161.     }
  162.     /**
  163.      * @return string
  164.      */
  165.     public function getAction(): string
  166.     {
  167.         return $this->action;
  168.     }
  169.     /**
  170.      * @param string $action
  171.      */
  172.     public function setAction(string $action): void
  173.     {
  174.         $this->action $action;
  175.     }
  176.     /**
  177.      * @return string|null
  178.      */
  179.     public function getMessage(): ?string
  180.     {
  181.         return $this->message;
  182.     }
  183.     /**
  184.      * @param string|null $message
  185.      */
  186.     public function setMessage(?string $message): void
  187.     {
  188.         $this->message $message;
  189.     }
  190.     /**
  191.      * @return string|null
  192.      */
  193.     public function getErrorMessage(): ?string
  194.     {
  195.         return $this->errorMessage;
  196.     }
  197.     /**
  198.      * @param string|null $errorMessage
  199.      */
  200.     public function setErrorMessage(?string $errorMessage): void
  201.     {
  202.         $this->errorMessage $errorMessage;
  203.     }
  204.     /**
  205.      * @return string|null
  206.      */
  207.     public function getStackTrace(): ?string
  208.     {
  209.         return $this->stackTrace;
  210.     }
  211.     /**
  212.      * @param string|null $stackTrace
  213.      */
  214.     public function setStackTrace(?string $stackTrace): void
  215.     {
  216.         $this->stackTrace $stackTrace;
  217.     }
  218.     /**
  219.      * @return string|null
  220.      */
  221.     public function getParameters(): ?string
  222.     {
  223.         return $this->parameters;
  224.     }
  225.     /**
  226.      * @param string|null $parameters
  227.      */
  228.     public function setParameters(?string $parameters): void
  229.     {
  230.         $this->parameters $parameters;
  231.     }
  232.     /**
  233.      * @return string
  234.      */
  235.     public function getController(): string
  236.     {
  237.         return $this->controller;
  238.     }
  239.     /**
  240.      * @param string $controller
  241.      */
  242.     public function setController(string $controller): void
  243.     {
  244.         $this->controller $controller;
  245.     }
  246.     /**
  247.      * @return string
  248.      */
  249.     public function getAplication(): string
  250.     {
  251.         return $this->aplication;
  252.     }
  253.     /**
  254.      * @param string $aplication
  255.      */
  256.     public function setAplication(string $aplication): void
  257.     {
  258.         $this->aplication $aplication;
  259.     }
  260.     /**
  261.      * @return string
  262.      */
  263.     public function getClientIp(): string
  264.     {
  265.         return $this->clientIp;
  266.     }
  267.     /**
  268.      * @param string $clientIp
  269.      */
  270.     public function setClientIp(string $clientIp): void
  271.     {
  272.         $this->clientIp $clientIp;
  273.     }
  274.     /**
  275.      * @return string
  276.      */
  277.     public function getRequestUri(): string
  278.     {
  279.         return $this->requestUri;
  280.     }
  281.     /**
  282.      * @param string $requestUri
  283.      */
  284.     public function setRequestUri(string $requestUri): void
  285.     {
  286.         $this->requestUri $requestUri;
  287.     }
  288.     /**
  289.      * @return string
  290.      */
  291.     public function getPort(): string
  292.     {
  293.         return $this->port;
  294.     }
  295.     /**
  296.      * @param string $port
  297.      */
  298.     public function setPort(string $port): void
  299.     {
  300.         $this->port $port;
  301.     }
  302.     /**
  303.      * @return string
  304.      */
  305.     public function getMethod(): string
  306.     {
  307.         return $this->method;
  308.     }
  309.     /**
  310.      * @param string $method
  311.      */
  312.     public function setMethod(string $method): void
  313.     {
  314.         $this->method $method;
  315.     }
  316.     /**
  317.      * @return DateTime
  318.      */
  319.     public function getCreatedAt(): DateTime
  320.     {
  321.         return $this->createdAt;
  322.     }
  323.     /**
  324.      * @param DateTime $createdAt
  325.      */
  326.     public function setCreatedAt(DateTime $createdAt): void
  327.     {
  328.         $this->createdAt $createdAt;
  329.     }
  330.     public function getPrettyParameters()
  331.     {
  332.         $params json_decode($this->getParameters(), true);
  333.         if (count($params) > 0) {
  334.             return json_encode($paramsJSON_PRETTY_PRINT);
  335.         }
  336.         return '-';
  337.     }
  338.     public function __toString()
  339.     {
  340.         return $this->getMessage() ?: $this->getErrorMessage();
  341.     }
  342. }