src/Cms/LogBundle/Entity/ActivityLog.php line 22

Open in your IDE?
  1. <?php
  2. namespace Cms\LogBundle\Entity;
  3. use Cms\TenantBundle\Entity\TenantedEntities\AnonymousTenantedEntity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Platform\SecurityBundle\Entity\Identity\Account;
  6. use Exception;
  7. /**
  8.  * Class Log
  9.  * @package Cms\LogBundle\Entity
  10.  *
  11.  * @ORM\Entity(
  12.  *  repositoryClass = "Cms\LogBundle\Doctrine\ActivityLogRepository"
  13.  * )
  14.  * @ORM\HasLifecycleCallbacks
  15.  * @ORM\Table(
  16.  *  name = "cms__log__activity_log"
  17.  * )
  18.  */
  19. class ActivityLog extends AnonymousTenantedEntity
  20. {
  21.     public const AUTH_TYPES = [
  22.         self::AUTH_TYPE__WEB,
  23.         self::AUTH_TYPE__API,
  24.     ];
  25.     public const AUTH_TYPE__WEB 1;
  26.     public const AUTH_TYPE__API 2;
  27.     /**
  28.      * @var string
  29.      *
  30.      * @ORM\Column(
  31.      *  type = "string",
  32.      *  nullable = false
  33.      * )
  34.      */
  35.     protected $ip;
  36.     /**
  37.      * @var string
  38.      *
  39.      * @ORM\Column(
  40.      *  type = "string",
  41.      *  nullable = false
  42.      * )
  43.      */
  44.     protected $action;
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(
  49.      *  type = "string",
  50.      *  nullable = false
  51.      * )
  52.      */
  53.     protected $objectId;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(
  58.      *  type = "string",
  59.      *  nullable = false
  60.      * )
  61.      */
  62.     protected $objectClass;
  63.     /**
  64.      * @var Account
  65.      *
  66.      * @ORM\ManyToOne(targetEntity="Platform\SecurityBundle\Entity\Identity\Account")
  67.      * @ORM\JoinColumn(name="account", referencedColumnName="id", onDelete="SET NULL")
  68.      */
  69.     protected $account;
  70.     /**
  71.      * @var Account
  72.      *
  73.      * @ORM\ManyToOne(targetEntity="Platform\SecurityBundle\Entity\Identity\Account")
  74.      * @ORM\JoinColumn(name="realAccount", referencedColumnName="id", onDelete="SET NULL")
  75.      */
  76.     protected $realAccount;
  77.     /**
  78.      * @var array
  79.      *
  80.      * @ORM\Column(
  81.      *     type = "json",
  82.      *     nullable = true
  83.      * )
  84.      */
  85.     protected $details;
  86.     /**
  87.      * @var int
  88.      *
  89.      * @ORM\Column(
  90.      *     type = "smallint",
  91.      *     nullable = false,
  92.      *     options = {
  93.      *         "default" = ActivityLog::AUTH_TYPE__WEB,
  94.      *     },
  95.      * )
  96.      */
  97.     protected int $authType self::AUTH_TYPE__WEB;
  98.     /**
  99.      * @return string
  100.      */
  101.     public function getIp()
  102.     {
  103.         return $this->ip;
  104.     }
  105.     /**
  106.      * @return string
  107.      */
  108.     public function getAction()
  109.     {
  110.         return $this->action;
  111.     }
  112.     /**
  113.      * @return int
  114.      */
  115.     public function getObjectId()
  116.     {
  117.         return $this->objectId;
  118.     }
  119.     /**
  120.      * @return string
  121.      */
  122.     public function getObjectClass()
  123.     {
  124.         return $this->objectClass;
  125.     }
  126.     /**
  127.      * @return Account
  128.      */
  129.     public function getAccount()
  130.     {
  131.         return $this->account;
  132.     }
  133.     /**
  134.      * @return Account
  135.      */
  136.     public function getRealAccount()
  137.     {
  138.         return $this->realAccount;
  139.     }
  140.     /**
  141.      * @return array|null
  142.      */
  143.     public function getDetails()
  144.     {
  145.         return $this->details;
  146.     }
  147.     /**
  148.      * @return int
  149.      */
  150.     public function getAuthType(): int
  151.     {
  152.         return $this->authType;
  153.     }
  154.     /**
  155.      * @param string $value
  156.      * @return $this
  157.      */
  158.     public function setIp($value)
  159.     {
  160.         $this->ip $value;
  161.         return $this;
  162.     }
  163.     /**
  164.      * @param string $value
  165.      * @return $this
  166.      */
  167.     public function setAction($value)
  168.     {
  169.         $this->action $value;
  170.         return $this;
  171.     }
  172.     /**
  173.      * @param int $value
  174.      * @return $this
  175.      */
  176.     public function setObjectId($value)
  177.     {
  178.         $this->objectId = (string) $value;
  179.         return $this;
  180.     }
  181.     /**
  182.      * @param string $value
  183.      * @return $this
  184.      */
  185.     public function setObjectClass($value)
  186.     {
  187.         $this->objectClass $value;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @param Account $value
  192.      * @return $this
  193.      */
  194.     public function setAccount(Account $value null)
  195.     {
  196.         $this->account $value;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @param Account $value
  201.      * @return $this
  202.      */
  203.     public function setRealAccount(Account $value null)
  204.     {
  205.         $this->realAccount $value;
  206.         return $this;
  207.     }
  208.     /**
  209.      * @param array|null $value
  210.      * @return $this
  211.      */
  212.     public function setDetails(array $value null)
  213.     {
  214.         $this->details $value;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @param int $authType
  219.      * @return $this
  220.      * @throws Exception
  221.      */
  222.     public function setAuthType(int $authType): self
  223.     {
  224.         if ( ! in_array($authTypeself::AUTH_TYPEStrue)) {
  225.             throw new Exception();
  226.         }
  227.         $this->authType $authType;
  228.         return $this;
  229.     }
  230. }