vendor/uvdesk/core-framework/Entity/User.php line 14

Open in your IDE?
  1. <?php
  2. namespace Webkul\UVDesk\CoreFrameworkBundle\Entity;
  3. use Symfony\Component\Security\Core\User\UserInterface;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * User
  7.  * @ORM\Entity(repositoryClass="Webkul\UVDesk\CoreFrameworkBundle\Repository\UserRepository")
  8.  * @ORM\HasLifecycleCallbacks()
  9.  * @ORM\Table(name="uv_user")
  10.  */
  11. class User implements UserInterface
  12. {
  13.     /**
  14.      * @var integer
  15.      * @ORM\Id()
  16.      * @ORM\Column(type="integer")
  17.      * @ORM\GeneratedValue(strategy="AUTO")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @var string
  22.      * @ORM\Column(type="string", length=191, unique=true, nullable=true)
  23.      */
  24.     private $email;
  25.     /**
  26.      * @var string
  27.      * @ORM\Column(type="string", length=191, unique=true, nullable=true)
  28.      */
  29.     private $proxyId;
  30.     /**
  31.      * @var string
  32.      * @ORM\Column(type="string", length=191, nullable=true)
  33.      */
  34.     private $password;
  35.     /**
  36.      * @var string
  37.      * @ORM\Column(type="string", length=191)
  38.      */
  39.     private $firstName;
  40.     /**
  41.      * @var string
  42.      * @ORM\Column(type="string", length=191, nullable=true)
  43.      */
  44.     private $lastName;
  45.     /**
  46.      * @var boolean
  47.      * @ORM\Column(type="boolean", options={"default": false})
  48.      */
  49.     private $isEnabled;
  50.     /**
  51.      * @var string
  52.      * @ORM\Column(type="string", length=191, unique=true, nullable=true)
  53.      */
  54.     private $verificationCode;
  55.     /**
  56.      * @var \Doctrine\Common\Collections\Collection
  57.      * @ORM\OneToMany(targetEntity="UserInstance", mappedBy="user")
  58.      */
  59.     private $userInstance;
  60.     /**
  61.      * @var array
  62.      */
  63.     private $grantedRoles = [];
  64.     /**
  65.      * @var \Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance
  66.      */
  67.     private $activeInstance;
  68.      /**
  69.      * @var string
  70.      * @ORM\Column(type="string", length=191, nullable=true)
  71.      */
  72.     private $timezone;
  73.     /**
  74.      * @var string
  75.      * @ORM\Column(type="string", length=191, nullable=true)
  76.      */
  77.     private $timeformat;
  78.     
  79.     /**
  80.      * @var \DateTime
  81.      * @ORM\Column(type="datetime", nullable=true)
  82.      */
  83.     private $lastOtpGeneratedAt;
  84.     /**
  85.      * Constructor
  86.      */
  87.     public function __construct()
  88.     {
  89.         $this->userInstance = new \Doctrine\Common\Collections\ArrayCollection();
  90.     }
  91.     /**
  92.      * Get id
  93.      *
  94.      * @return integer
  95.      */
  96.     public function getId()
  97.     {
  98.         return $this->id;
  99.     }
  100.     /**
  101.      * Set lastOtpGeneratedAt
  102.      *
  103.      * @param \DateTime $lastOtpGeneratedAt
  104.      *     
  105.      */
  106.     public function setLastOtpGeneratedAt($lastOtpGeneratedAt)
  107.     {
  108.         $this->lastOtpGeneratedAt $lastOtpGeneratedAt;
  109.         return $this;
  110.     }
  111.     /**
  112.      * Get lastOtpGeneratedAt
  113.      *
  114.      * @return \DateTime
  115.      */
  116.     public function getLastOtpGeneratedAt()
  117.     {
  118.         return $this->lastOtpGeneratedAt;
  119.     }
  120.     /**
  121.      * Set email
  122.      *
  123.      * @param string $email
  124.      *
  125.      * @return User
  126.      */
  127.     public function setEmail($email)
  128.     {
  129.         $this->email $email;
  130.         return $this;
  131.     }
  132.     /**
  133.      * Get email
  134.      *
  135.      * @return string
  136.      */
  137.     public function getEmail()
  138.     {
  139.         return $this->email;
  140.     }
  141.     /**
  142.      * Set proxyId
  143.      *
  144.      * @param string $proxyId
  145.      *
  146.      * @return User
  147.      */
  148.     public function setProxyId($proxyId)
  149.     {
  150.         $this->proxyId $proxyId;
  151.         return $this;
  152.     }
  153.     /**
  154.      * Get proxyId
  155.      *
  156.      * @return string
  157.      */
  158.     public function getProxyId()
  159.     {
  160.         return $this->proxyId;
  161.     }
  162.     /**
  163.      * Get username
  164.      *
  165.      * @return string
  166.      */
  167.     public function getUsername()
  168.     {
  169.         return $this->email;
  170.     }
  171.     /**
  172.      * Set password
  173.      *
  174.      * @param string $password
  175.      *
  176.      * @return User
  177.      */
  178.     public function setPassword($password)
  179.     {
  180.         $this->password $password;
  181.         return $this;
  182.     }
  183.     /**
  184.      * Get password
  185.      *
  186.      * @return string
  187.      */
  188.     public function getPassword()
  189.     {
  190.         return $this->password;
  191.     }
  192.     /**
  193.      * Get salt
  194.      *
  195.      * @return string
  196.      */
  197.     public function getSalt()
  198.     {
  199.         return null;
  200.     }
  201.     /**
  202.      * Set user instance's granted roles
  203.      *
  204.      * @param array $grantedRoles
  205.      *
  206.      * @return User
  207.      */
  208.     public function setRoles(array $grantedRoles = [])
  209.     {
  210.         $this->grantedRoles $grantedRoles;
  211.         return $this;
  212.     }
  213.     /**
  214.      * Get user's granted roles
  215.      *
  216.      * @return array
  217.      */
  218.     public function getRoles()
  219.     {
  220.         return $this->grantedRoles;
  221.     }
  222.     /**
  223.      * Set firstName
  224.      *
  225.      * @param string $firstName
  226.      *
  227.      * @return User
  228.      */
  229.     public function setFirstName($firstName)
  230.     {
  231.         $this->firstName $firstName;
  232.         return $this;
  233.     }
  234.     /**
  235.      * Get firstName
  236.      *
  237.      * @return string
  238.      */
  239.     public function getFirstName()
  240.     {
  241.         return $this->firstName;
  242.     }
  243.     /**
  244.      * Set lastName
  245.      *
  246.      * @param string $lastName
  247.      *
  248.      * @return User
  249.      */
  250.     public function setLastName($lastName)
  251.     {
  252.         $this->lastName $lastName;
  253.         return $this;
  254.     }
  255.     /**
  256.      * Get lastName
  257.      *
  258.      * @return string
  259.      */
  260.     public function getLastName()
  261.     {
  262.         return $this->lastName;
  263.     }
  264.     /**
  265.      * Get fullName
  266.      *
  267.      * @return string
  268.      */
  269.     public function getFullName()
  270.     {
  271.         return trim(implode(' ', array($this->getFirstName(), $this->getLastName())));
  272.     }
  273.     /**
  274.      * Set isEnabled
  275.      *
  276.      * @param boolean $isEnabled
  277.      *
  278.      * @return User
  279.      */
  280.     public function setIsEnabled($isEnabled)
  281.     {
  282.         $this->isEnabled $isEnabled;
  283.         return $this;
  284.     }
  285.     /**
  286.      * Get isEnabled
  287.      *
  288.      * @return boolean
  289.      */
  290.     public function getIsEnabled()
  291.     {
  292.         return $this->isEnabled;
  293.     }
  294.     /**
  295.      * Set verificationCode
  296.      *
  297.      * @param string $verificationCode
  298.      *
  299.      * @return User
  300.      */
  301.     public function setVerificationCode($verificationCode)
  302.     {
  303.         $this->verificationCode $verificationCode;
  304.         return $this;
  305.     }
  306.     /**
  307.      * Get email
  308.      *
  309.      * @return string
  310.      */
  311.     public function getVerificationCode()
  312.     {
  313.         return $this->verificationCode;
  314.     }
  315.     /**
  316.      * Clears not so important user's credentials
  317.      *
  318.      * @return void
  319.      */
  320.     public function eraseCredentials()
  321.     {
  322.         return;
  323.     }
  324.     /**
  325.      * Checks whether the user's account has expired
  326.      *
  327.      * @return bool
  328.      */
  329.     public function isAccountNonExpired()
  330.     {
  331.         return true;
  332.     }
  333.     /**
  334.      * Checks whether the user is locked
  335.      *
  336.      * @return bool
  337.      */
  338.     public function isAccountNonLocked()
  339.     {
  340.         return true;
  341.     }
  342.     /**
  343.      * Checks whether the user's credentials has expired
  344.      *
  345.      * @return bool
  346.      */
  347.     public function isCredentialsNonExpired()
  348.     {
  349.         return true;
  350.     }
  351.     /**
  352.      * Checks whether the user is enabled
  353.      *
  354.      * @return bool
  355.      */
  356.     public function isEnabled()
  357.     {
  358.         return $this->isEnabled;
  359.     }
  360.     /**
  361.      * Add userInstance
  362.      *
  363.      * @param \Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance $userInstance
  364.      *
  365.      * @return User
  366.      */
  367.     public function addUserInstance(\Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance $userInstance)
  368.     {
  369.         $this->userInstance[] = $userInstance;
  370.         return $this;
  371.     }
  372.     /**
  373.      * Remove userInstance
  374.      *
  375.      * @param \Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance $userInstance
  376.      */
  377.     public function removeUserInstance(\Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance $userInstance)
  378.     {
  379.         $this->userInstance->removeElement($userInstance);
  380.     }
  381.     /**
  382.      * Get userInstance
  383.      *
  384.      * @return \Doctrine\Common\Collections\Collection
  385.      */
  386.     public function getUserInstance()
  387.     {
  388.         return $this->userInstance;
  389.     }
  390.     public function getAgentInstance()
  391.     {
  392.         foreach ($this->getUserInstance()->getValues() as $userInstance) {
  393.             if (in_array($userInstance->getSupportRole()->getCode(), ['ROLE_AGENT''ROLE_ADMIN''ROLE_SUPER_ADMIN'])) {
  394.                 return $userInstance;
  395.             }
  396.         }
  397.         return null;
  398.     }
  399.     public function getCustomerInstance()
  400.     {
  401.         foreach ($this->getUserInstance()->getValues() as $userInstance) {
  402.             if (in_array($userInstance->getSupportRole()->getCode(), ['ROLE_CUSTOMER''ROLE_CUSTOMER_READ_ONLY'])) {
  403.                 return $userInstance;
  404.             }
  405.         }
  406.         return null;
  407.     }
  408.     /**
  409.      * Set currently active user instance
  410.      *
  411.      * @param \Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance $userInstance
  412.      *
  413.      * @return User
  414.      */
  415.     public function setCurrentInstance(\Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance $userInstance null)
  416.     {
  417.         $this->activeInstance $userInstance;
  418.         return $this;
  419.     }
  420.     /**
  421.      * Get currently active user instance
  422.      *
  423.      * @return \Webkul\UVDesk\CoreFrameworkBundle\Entity\UserInstance
  424.      */
  425.     public function getCurrentInstance()
  426.     {
  427.         return $this->activeInstance;
  428.     }
  429.     /**
  430.      * Set timezone
  431.      *
  432.      * @param string $timezone
  433.      * @return User
  434.      */
  435.     public function setTimezone($timezone)
  436.     {
  437.         $this->timezone $timezone;
  438.         return $this;
  439.     }
  440.     /**
  441.      * Get timezone
  442.      *
  443.      * @return string
  444.      */
  445.     public function getTimezone()
  446.     {
  447.         return $this->timezone;
  448.     }
  449.     /**
  450.      * Set timeformat
  451.      *
  452.      * @param string $timeformat
  453.      * @return User
  454.      */
  455.     public function setTimeformat($timeformat)
  456.     {
  457.         $this->timeformat $timeformat;
  458.         return $this;
  459.     }
  460.     /**
  461.      * Get timeformat
  462.      *
  463.      * @return string
  464.      */
  465.     public function getTimeformat()
  466.     {
  467.         return $this->timeformat;
  468.     }
  469. }