<?php
namespace Cms\LogBundle\Entity;
use Cms\TenantBundle\Entity\TenantedEntities\AnonymousTenantedEntity;
use Doctrine\ORM\Mapping as ORM;
use Platform\SecurityBundle\Entity\Identity\Account;
use Exception;
/**
* Class Log
* @package Cms\LogBundle\Entity
*
* @ORM\Entity(
* repositoryClass = "Cms\LogBundle\Doctrine\ActivityLogRepository"
* )
* @ORM\HasLifecycleCallbacks
* @ORM\Table(
* name = "cms__log__activity_log"
* )
*/
class ActivityLog extends AnonymousTenantedEntity
{
public const AUTH_TYPES = [
self::AUTH_TYPE__WEB,
self::AUTH_TYPE__API,
];
public const AUTH_TYPE__WEB = 1;
public const AUTH_TYPE__API = 2;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $ip;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $action;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $objectId;
/**
* @var string
*
* @ORM\Column(
* type = "string",
* nullable = false
* )
*/
protected $objectClass;
/**
* @var Account
*
* @ORM\ManyToOne(targetEntity="Platform\SecurityBundle\Entity\Identity\Account")
* @ORM\JoinColumn(name="account", referencedColumnName="id", onDelete="SET NULL")
*/
protected $account;
/**
* @var Account
*
* @ORM\ManyToOne(targetEntity="Platform\SecurityBundle\Entity\Identity\Account")
* @ORM\JoinColumn(name="realAccount", referencedColumnName="id", onDelete="SET NULL")
*/
protected $realAccount;
/**
* @var array
*
* @ORM\Column(
* type = "json",
* nullable = true
* )
*/
protected $details;
/**
* @var int
*
* @ORM\Column(
* type = "smallint",
* nullable = false,
* options = {
* "default" = ActivityLog::AUTH_TYPE__WEB,
* },
* )
*/
protected int $authType = self::AUTH_TYPE__WEB;
/**
* @return string
*/
public function getIp()
{
return $this->ip;
}
/**
* @return string
*/
public function getAction()
{
return $this->action;
}
/**
* @return int
*/
public function getObjectId()
{
return $this->objectId;
}
/**
* @return string
*/
public function getObjectClass()
{
return $this->objectClass;
}
/**
* @return Account
*/
public function getAccount()
{
return $this->account;
}
/**
* @return Account
*/
public function getRealAccount()
{
return $this->realAccount;
}
/**
* @return array|null
*/
public function getDetails()
{
return $this->details;
}
/**
* @return int
*/
public function getAuthType(): int
{
return $this->authType;
}
/**
* @param string $value
* @return $this
*/
public function setIp($value)
{
$this->ip = $value;
return $this;
}
/**
* @param string $value
* @return $this
*/
public function setAction($value)
{
$this->action = $value;
return $this;
}
/**
* @param int $value
* @return $this
*/
public function setObjectId($value)
{
$this->objectId = (string) $value;
return $this;
}
/**
* @param string $value
* @return $this
*/
public function setObjectClass($value)
{
$this->objectClass = $value;
return $this;
}
/**
* @param Account $value
* @return $this
*/
public function setAccount(Account $value = null)
{
$this->account = $value;
return $this;
}
/**
* @param Account $value
* @return $this
*/
public function setRealAccount(Account $value = null)
{
$this->realAccount = $value;
return $this;
}
/**
* @param array|null $value
* @return $this
*/
public function setDetails(array $value = null)
{
$this->details = $value;
return $this;
}
/**
* @param int $authType
* @return $this
* @throws Exception
*/
public function setAuthType(int $authType): self
{
if ( ! in_array($authType, self::AUTH_TYPES, true)) {
throw new Exception();
}
$this->authType = $authType;
return $this;
}
}