src/Document/Security/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Document\Security;
  3. use App\Document\Authorization\UserLevelAuthorization;
  4. use App\Document\Common\LegalEntity;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
  10. /**
  11.  * @MongoDB\Document(repositoryClass="App\Repository\Security\UserRepository")
  12.  * @MongoDBUnique(fields="username")
  13.  */
  14. class User implements UserInterface\Serializable
  15. {
  16.     /**
  17.      * @MongoDB\Id
  18.      */
  19.     protected $id;
  20.     /**
  21.      * @MongoDB\Field(type="string")
  22.      */
  23.     protected $username;
  24.     /**
  25.      * @MongoDB\Field(type="string")
  26.      */
  27.     protected $password;
  28.     /**
  29.      * @MongoDB\Field(type="string")
  30.      * @Assert\Blank()
  31.      */
  32.     protected $salt;
  33.     /**
  34.      * @MongoDB\Field(type="boolean")
  35.      */
  36.     protected $isActive;
  37.     /**
  38.      * @MongoDB\Field(type="boolean")
  39.      */
  40.     protected $status;
  41.     /**
  42.      * @MongoDB\ReferenceOne(targetDocument="App\Document\Security\Role",cascade={"persist"})
  43.      */
  44.     protected $role;
  45.     /**
  46.      * @MongoDB\EmbedOne (targetDocument="App\Document\Security\UserProfile")
  47.      */
  48.     protected $userProfile;
  49.     /**
  50.      * @MongoDB\Field(type="string")
  51.      */
  52.     protected $apiKey;
  53.     /**
  54.      * @MongoDB\Field(type="date")
  55.      */
  56.     protected $lastLoginAt;
  57.     /**
  58.      * @MongoDB\ReferenceMany(targetDocument="App\Document\Device\Device",cascade={"persist"})
  59.      */
  60.     protected $blockedDevices;
  61.     /**
  62.      * @MongoDB\ReferenceOne(targetDocument="App\Document\Common\LegalEntity")
  63.      */
  64.     protected $legalEntity;
  65.     /**
  66.      * @MongoDB\Field(type="string")
  67.      */
  68.     protected $legalEntityMeta;
  69.     /**
  70.      * @MongoDB\Field(type="string")
  71.      */
  72.     protected $primaryRole;
  73.     /**
  74.      * @MongoDB\Field(type="integer")
  75.      */
  76.     protected $accessRoleLevel;
  77.     /**
  78.      * @MongoDB\Field(type="integer")
  79.      */
  80.     protected $systemAccessLevel;
  81.     /**
  82.      * @MongoDB\ReferenceOne(targetDocument="App\Document\Authorization\UserLevelAuthorization",cascade={"persist"})
  83.      */
  84.     protected $userLevelAuthorization;
  85.     public function __construct()
  86.     {
  87.         $this->userProfile = new UserProfile();
  88.         $this->isActive true;
  89.         $this->status true;
  90.         $this->accessRoleLevel 0;
  91.     }
  92.     public function getRoles()
  93.     {
  94.         $roles[] = $this->role->getMetaCode();
  95.         return $roles;
  96.     }
  97.     /**
  98.      * @return mixed
  99.      */
  100.     public function getPrimaryRole()
  101.     {
  102.         return $this->primaryRole;
  103.     }
  104.     /**
  105.      * @param mixed $primaryRole
  106.      */
  107.     public function setPrimaryRole($primaryRole)
  108.     {
  109.         $this->primaryRole $primaryRole;
  110.     }
  111.     /**
  112.      * @return string|null
  113.      */
  114.     public function getPassword()
  115.     {
  116.         return $this->password;
  117.     }
  118.     public function setPassword($password): User
  119.     {
  120.         $this->password $password;
  121.         return $this;
  122.     }
  123.     public function getSalt()
  124.     {
  125.         return $this->salt;
  126.     }
  127.     public function getUsername()
  128.     {
  129.         return $this->username;
  130.     }
  131.     public function setUsername($username)
  132.     {
  133.         $this->username $username;
  134.     }
  135.     public function eraseCredentials()
  136.     {
  137.         // TODO: Implement eraseCredentials() method.
  138.     }
  139.     public function serialize()
  140.     {
  141.         return serialize(array(
  142.             $this->id,
  143.             $this->username,
  144.             $this->password,
  145.             $this->userProfile,
  146.             // see section on salt below
  147.             // $this->salt,
  148.         ));
  149.     }
  150.     public function unserialize($serialized)
  151.     {
  152.         list (
  153.             $this->id,
  154.             $this->username,
  155.             $this->password,
  156.             $this->userProfile,
  157.             // see section on salt below
  158.             // $this->salt
  159.             ) = unserialize($serialized, array('allowed_classes' => true));
  160.     }
  161.     /**
  162.      * @return mixed
  163.      */
  164.     public function getId()
  165.     {
  166.         return $this->id;
  167.     }
  168.     /**
  169.      * @return bool
  170.      */
  171.     public function getIsActive(): bool
  172.     {
  173.         return $this->isActive;
  174.     }
  175.     /**
  176.      * @param bool $isActive
  177.      */
  178.     public function setIsActive($isActive): void
  179.     {
  180.         $this->isActive $isActive;
  181.     }
  182.     /**
  183.      * @return bool
  184.      */
  185.     public function getStatus(): bool
  186.     {
  187.         return $this->status;
  188.     }
  189.     /**
  190.      * @param bool $status
  191.      */
  192.     public function setStatus($status): void
  193.     {
  194.         $this->status $status;
  195.     }
  196.     /**
  197.      * @return Role
  198.      */
  199.     public function getRole()
  200.     {
  201.         return $this->role;
  202.     }
  203.     /**
  204.      * @param mixed $role
  205.      */
  206.     public function setRole($role): void
  207.     {
  208.         $this->role $role;
  209.     }
  210.     /**
  211.      * @return UserProfile
  212.      */
  213.     public function getUserProfile():UserProfile
  214.     {
  215.         return $this->userProfile;
  216.     }
  217.     /**
  218.      * @param mixed $userProfile
  219.      */
  220.     public function setUserProfile($userProfile): void
  221.     {
  222.         $this->userProfile $userProfile;
  223.     }
  224.     /**
  225.      * @return mixed
  226.      */
  227.     public function getApiKey()
  228.     {
  229.         return $this->apiKey;
  230.     }
  231.     /**
  232.      * @param mixed $apiKey
  233.      */
  234.     public function setApiKey($apiKey): void
  235.     {
  236.         $this->apiKey $apiKey;
  237.     }
  238.     /**
  239.      * @return mixed
  240.      */
  241.     public function getLastLoginAt()
  242.     {
  243.         return $this->lastLoginAt;
  244.     }
  245.     /**
  246.      * @param mixed $lastLoginAt
  247.      */
  248.     public function setLastLoginAt($lastLoginAt): void
  249.     {
  250.         $this->lastLoginAt $lastLoginAt;
  251.     }
  252.     /**
  253.      * @return mixed
  254.      */
  255.     public function getBlockedDevices()
  256.     {
  257.         return $this->blockedDevices;
  258.     }
  259.     /**
  260.      * @param mixed $blockedDevices
  261.      */
  262.     public function setBlockedDevices($blockedDevices): void
  263.     {
  264.         $this->blockedDevices $blockedDevices;
  265.     }
  266.     /**
  267.      * @return LegalEntity $legalEntity
  268.      */
  269.     public function getLegalEntity()
  270.     {
  271.         return $this->legalEntity;
  272.     }
  273.     /**
  274.      * @param mixed $legalEntity
  275.      */
  276.     public function setLegalEntity($legalEntity): void
  277.     {
  278.         $this->legalEntity $legalEntity;
  279.     }
  280.     /**
  281.      * @param mixed $salt
  282.      */
  283.     public function setSalt($salt): void
  284.     {
  285.         $this->salt $salt;
  286.     }
  287.     /**
  288.      * @return mixed
  289.      */
  290.     public function getLegalEntityMeta()
  291.     {
  292.         return $this->legalEntityMeta;
  293.     }
  294.     /**
  295.      * @param mixed $legalEntityMeta
  296.      */
  297.     public function setLegalEntityMeta($legalEntityMeta): void
  298.     {
  299.         $this->legalEntityMeta $legalEntityMeta;
  300.     }
  301.     /**
  302.      * @return int
  303.      */
  304.     public function getAccessRoleLevel(): int
  305.     {
  306.         return $this->accessRoleLevel;
  307.     }
  308.     /**
  309.      * @param int $accessRoleLevel
  310.      */
  311.     public function setAccessRoleLevel(int $accessRoleLevel): void
  312.     {
  313.         $this->accessRoleLevel $accessRoleLevel;
  314.     }
  315.     /**
  316.      * @return ?UserLevelAuthorization
  317.      */
  318.     public function getUserLevelAuthorization():?UserLevelAuthorization
  319.     {
  320.         return $this->userLevelAuthorization;
  321.     }
  322.     /**
  323.      * @param mixed $userLevelAuthorization
  324.      */
  325.     public function setUserLevelAuthorization($userLevelAuthorization): void
  326.     {
  327.         $this->userLevelAuthorization $userLevelAuthorization;
  328.     }
  329.     /**
  330.      * @return mixed
  331.      */
  332.     public function getSystemAccessLevel()
  333.     {
  334.         return $this->systemAccessLevel;
  335.     }
  336.     /**
  337.      * @param mixed $systemAccessLevel
  338.      */
  339.     public function setSystemAccessLevel($systemAccessLevel): void
  340.     {
  341.         $this->systemAccessLevel $systemAccessLevel;
  342.     }
  343. }