src/Document/ExternalAPI/APIUser.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Document\ExternalAPI;
  3. use App\Document\Security\Role;
  4. use Symfony\Component\Security\Core\User\UserInterface;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
  7. use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  8. /**
  9.  * @MongoDB\Document(repositoryClass="App\Repository\ExternalAPI\APIUserRepository")
  10.  * @MongoDBUnique(fields="username")
  11.  */
  12. class APIUser implements UserInterface\Serializable
  13. {
  14.     /**
  15.      * @MongoDB\Id
  16.      */
  17.     protected $id;
  18.     /**
  19.      * @MongoDB\Field(type="string")
  20.      */
  21.     protected $username;
  22.     /**
  23.      * @MongoDB\Field(type="string")
  24.      */
  25.     protected $password;
  26.     /**
  27.      * @MongoDB\Field(type="string")
  28.      */
  29.     protected $fullName;
  30.     /**
  31.      * @MongoDB\Field(type="string")
  32.      */
  33.     protected $nic;
  34.     /**
  35.      * @MongoDB\Field(type="string")
  36.      */
  37.     protected $email;
  38.     /**
  39.      * @MongoDB\ReferenceOne(targetDocument="App\Document\ExternalAPI\APIRole")
  40.      */
  41.     protected $role;
  42.     /**
  43.      * @MongoDB\Field(type="string")
  44.      */
  45.     protected $roleCode;
  46.     /**
  47.      * @MongoDB\Field(type="string")
  48.      */
  49.     protected $primaryContact;
  50.     /**
  51.      * @MongoDB\Field(type="string")
  52.      * @Assert\Blank()
  53.      */
  54.     protected $salt;
  55.     /**
  56.      * @MongoDB\Field(type="boolean")
  57.      */
  58.     protected $isActive;
  59.     /**
  60.      * @MongoDB\Field(type="boolean")
  61.      */
  62.     protected $status;
  63.     /**
  64.      * @MongoDB\Field(type="date")
  65.      */
  66.     protected $lastLoginAt;
  67.     /**
  68.      * @MongoDB\Field(type="date")
  69.      */
  70.     protected $createdAt;
  71.     /**
  72.      * @MongoDB\Field(type="date")
  73.      */
  74.     protected $updatedAt;
  75.     /**
  76.      * @MongoDB\ReferenceOne(targetDocument="App\Document\Security\User",cascade={"persist"})
  77.      */
  78.     protected $updatedBy;
  79.     /**
  80.      * @MongoDB\ReferenceOne(targetDocument="App\Document\Common\LegalEntity")
  81.      */
  82.     protected $legalEntity;
  83.     /**
  84.      * @MongoDB\Field(type="string")
  85.      */
  86.     protected $legalEntityMeta;
  87.     /**
  88.      * @MongoDB\Field(type="boolean")
  89.      */
  90.     protected $isSignIn;
  91.     /**
  92.      * @MongoDB\Field(type="boolean")
  93.      */
  94.     protected $isSingleLogin;
  95.     /**
  96.      * @MongoDB\ReferenceOne(targetDocument="App\Document\Common\LegalEntity")
  97.      */
  98.     protected $activeAccessToken;
  99.     public function __construct()
  100.     {
  101.         $this->isSingleLogin false;
  102.         $this->isActive true;
  103.         $this->status true;
  104.         $this->isSignIn false;
  105.         $this->createdAt = new \DateTime('now', new \DateTimeZone('Asia/Colombo'));
  106.     }
  107.     /**
  108.      * @return mixed
  109.      */
  110.     public function getId()
  111.     {
  112.         return $this->id;
  113.     }
  114.     /**
  115.      * @return mixed
  116.      */
  117.     public function getUsername()
  118.     {
  119.         return $this->username;
  120.     }
  121.     /**
  122.      * @param mixed $username
  123.      */
  124.     public function setUsername($username): void
  125.     {
  126.         $this->username $username;
  127.     }
  128.     /**
  129.      * @return mixed
  130.      */
  131.     public function getPassword()
  132.     {
  133.         return $this->password;
  134.     }
  135.     /**
  136.      * @param mixed $password
  137.      */
  138.     public function setPassword($password): void
  139.     {
  140.         $this->password $password;
  141.     }
  142.     /**
  143.      * @return mixed
  144.      */
  145.     public function getFullName()
  146.     {
  147.         return $this->fullName;
  148.     }
  149.     /**
  150.      * @param mixed $fullName
  151.      */
  152.     public function setFullName($fullName): void
  153.     {
  154.         $this->fullName $fullName;
  155.     }
  156.     /**
  157.      * @return mixed
  158.      */
  159.     public function getNic()
  160.     {
  161.         return $this->nic;
  162.     }
  163.     /**
  164.      * @param mixed $nic
  165.      */
  166.     public function setNic($nic): void
  167.     {
  168.         $this->nic $nic;
  169.     }
  170.     /**
  171.      * @return mixed
  172.      */
  173.     public function getEmail()
  174.     {
  175.         return $this->email;
  176.     }
  177.     /**
  178.      * @param mixed $email
  179.      */
  180.     public function setEmail($email): void
  181.     {
  182.         $this->email $email;
  183.     }
  184.     /**
  185.      * @return mixed
  186.      */
  187.     public function getPrimaryContact()
  188.     {
  189.         return $this->primaryContact;
  190.     }
  191.     /**
  192.      * @param mixed $primaryContact
  193.      */
  194.     public function setPrimaryContact($primaryContact): void
  195.     {
  196.         $this->primaryContact $primaryContact;
  197.     }
  198.     /**
  199.      * @return mixed
  200.      */
  201.     public function getSalt()
  202.     {
  203.         return $this->salt;
  204.     }
  205.     /**
  206.      * @param mixed $salt
  207.      */
  208.     public function setSalt($salt): void
  209.     {
  210.         $this->salt $salt;
  211.     }
  212.     /**
  213.      * @return bool
  214.      */
  215.     public function isActive(): bool
  216.     {
  217.         return $this->isActive;
  218.     }
  219.     /**
  220.      * @param bool $isActive
  221.      */
  222.     public function setIsActive(bool $isActive): void
  223.     {
  224.         $this->isActive $isActive;
  225.     }
  226.     /**
  227.      * @return bool
  228.      */
  229.     public function isStatus(): bool
  230.     {
  231.         return $this->status;
  232.     }
  233.     /**
  234.      * @param bool $status
  235.      */
  236.     public function setStatus(bool $status): void
  237.     {
  238.         $this->status $status;
  239.     }
  240.     /**
  241.      * @return mixed
  242.      */
  243.     public function getLastLoginAt()
  244.     {
  245.         return $this->lastLoginAt;
  246.     }
  247.     /**
  248.      * @param mixed $lastLoginAt
  249.      */
  250.     public function setLastLoginAt($lastLoginAt): void
  251.     {
  252.         $this->lastLoginAt $lastLoginAt;
  253.     }
  254.     /**
  255.      * @return mixed
  256.      */
  257.     public function getCreatedAt()
  258.     {
  259.         return $this->createdAt;
  260.     }
  261.     /**
  262.      * @param mixed $createdAt
  263.      */
  264.     public function setCreatedAt($createdAt): void
  265.     {
  266.         $this->createdAt $createdAt;
  267.     }
  268.     /**
  269.      * @return mixed
  270.      */
  271.     public function getUpdatedBy()
  272.     {
  273.         return $this->updatedBy;
  274.     }
  275.     /**
  276.      * @param mixed $updatedBy
  277.      */
  278.     public function setUpdatedBy($updatedBy): void
  279.     {
  280.         $this->updatedBy $updatedBy;
  281.     }
  282.     /**
  283.      * @return mixed
  284.      */
  285.     public function getLegalEntity()
  286.     {
  287.         return $this->legalEntity;
  288.     }
  289.     /**
  290.      * @param mixed $legalEntity
  291.      */
  292.     public function setLegalEntity($legalEntity): void
  293.     {
  294.         $this->legalEntity $legalEntity;
  295.     }
  296.     /**
  297.      * @return mixed
  298.      */
  299.     public function getLegalEntityMeta()
  300.     {
  301.         return $this->legalEntityMeta;
  302.     }
  303.     /**
  304.      * @param mixed $legalEntityMeta
  305.      */
  306.     public function setLegalEntityMeta($legalEntityMeta): void
  307.     {
  308.         $this->legalEntityMeta $legalEntityMeta;
  309.     }
  310.     public function serialize()
  311.     {
  312.         return serialize(array(
  313.             $this->id,
  314.             $this->username,
  315.             $this->password,
  316.             // see section on salt below
  317.             // $this->salt,
  318.         ));
  319.     }
  320.     public function unserialize($data)
  321.     {
  322.         list (
  323.             $this->id,
  324.             $this->username,
  325.             $this->password,
  326.             // see section on salt below
  327.             // $this->salt
  328.             ) = unserialize($data, array('allowed_classes' => true));
  329.     }
  330.     /**
  331.      * @return mixed
  332.      */
  333.     public function getRole():APIRole
  334.     {
  335.         return $this->role;
  336.     }
  337.     /**
  338.      * @param mixed $role
  339.      */
  340.     public function setRole($role): void
  341.     {
  342.         $this->role $role;
  343.     }
  344.     public function getRoles()
  345.     {
  346.         return [$this->getRole()->getCode()];
  347.     }
  348.     public function eraseCredentials()
  349.     {
  350.         // TODO: Implement eraseCredentials() method.
  351.     }
  352.     /**
  353.      * @return mixed
  354.      */
  355.     public function getRoleCode()
  356.     {
  357.         return $this->roleCode;
  358.     }
  359.     /**
  360.      * @param mixed $roleCode
  361.      */
  362.     public function setRoleCode($roleCode): void
  363.     {
  364.         $this->roleCode $roleCode;
  365.     }
  366.     public function getIsSignIn(): ?bool
  367.     {
  368.         return $this->isSignIn;
  369.     }
  370.     public function setIsSignIn(bool $isSignIn): void
  371.     {
  372.         $this->isSignIn $isSignIn;
  373.     }
  374.     public function getIsSingleLogin(): ?bool
  375.     {
  376.         return $this->isSingleLogin;
  377.     }
  378.     public function setIsSingleLogin(bool $isSingleLogin): void
  379.     {
  380.         $this->isSingleLogin $isSingleLogin;
  381.     }
  382.     /**
  383.      * @return mixed
  384.      */
  385.     public function getUpdatedAt()
  386.     {
  387.         return $this->updatedAt;
  388.     }
  389.     /**
  390.      * @param mixed $updatedAt
  391.      */
  392.     public function setUpdatedAt($updatedAt): void
  393.     {
  394.         $this->updatedAt $updatedAt;
  395.     }
  396.     /**
  397.      * @return mixed
  398.      */
  399.     public function getActiveAccessToken()
  400.     {
  401.         return $this->activeAccessToken;
  402.     }
  403.     /**
  404.      * @param mixed $activeAccessToken
  405.      */
  406.     public function setActiveAccessToken($activeAccessToken): void
  407.     {
  408.         $this->activeAccessToken $activeAccessToken;
  409.     }
  410. }