Guest User

Untitled

a guest
Dec 9th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.29 KB | None | 0 0
  1. <?php
  2.  
  3. namespace CMS\SecurityBundle\Entity;
  4.  
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Doctrine\ORM\Mapping as ORM;
  8.  
  9. /**
  10.  * CMS\SecurityBundle\Entity\Security
  11.  *
  12.  * @ORM\Table()
  13.  * @ORM\Entity(repositoryClass="CMS\SecurityBundle\Entity\SecurityRepository")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class Security implements UserInterface
  17. {
  18.     /**
  19.      * @var integer $id
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     private $id;
  26.  
  27.     /**
  28.      * @var string $username
  29.      *
  30.      * @ORM\Column(name="username", type="string", length=255, unique=true)
  31.      * @Assert\MinLength(limit=3, groups={"create"})
  32.      * @Assert\MaxLength(limit=15, groups={"create"})
  33.      */
  34.     private $username;
  35.  
  36.     /**
  37.      * @var string $password
  38.      *
  39.      * @ORM\Column(name="password", type="string", length=255)
  40.      */
  41.     private $password;
  42.  
  43.     /**
  44.      * Non encrypted password used for forms
  45.      *
  46.      * @var string $plainTextPassword
  47.      * @Assert\MinLength(limit=5, groups={"create","update"})
  48.      * @Assert\MaxLength(limit=15, groups={"create","update"})
  49.      * @Assert\NotBlank(groups={"create"})
  50.      */
  51.     private $plainTextPassword;
  52.  
  53.     /**
  54.      * @var string $email
  55.      *
  56.      * @ORM\Column(name="email", type="string", length=255, nullable=true, unique=true)
  57.      * @Assert\Email(groups={"create"})
  58.      */
  59.     private $email;
  60.  
  61.     /**
  62.      * @var integer $role
  63.      *
  64.      * @ORM\Column(name="role", type="integer")
  65.      * @Assert\NotBlank(groups={"create"})
  66.      * @Assert\Choice( choices = {1,2,3,4} )
  67.      */
  68.     private $role;
  69.    
  70.    
  71.     private $roles = array( 1 => 'ROLE_SUPER_ADMIN', 2 => 'ROLE_ADMIN', 3 => 'ROLE_SUPER_MODERATOR', 4 => 'ROLE_MODERATOR' );
  72.  
  73.     /**
  74.      * @var integer $status
  75.      *
  76.      * @ORM\Column(name="status", type="integer")
  77.      * @Assert\Choice( choices = {1,2} )
  78.      */
  79.     private $status;
  80.  
  81.     /**
  82.      * @var datetime $create_date
  83.      *
  84.      * @ORM\Column(name="create_date", type="datetime")
  85.      */
  86.     private $create_date;
  87.  
  88.     /**
  89.      * @var integer $creator
  90.      *
  91.      * @ORM\Column(name="creator", type="integer")
  92.      * @Assert\Type( type="integer" )
  93.      * @Assert\Min( limit=1)
  94.      */
  95.     private $creator;
  96.  
  97.     /**
  98.      * @var datetime $last_update
  99.      *
  100.      * @ORM\Column(name="last_update", type="datetime", nullable=true)
  101.      */
  102.     private $last_update;
  103.    
  104.    
  105.     /**
  106.      * @var type datetime $last_visit
  107.      *
  108.      * @ORM\Column(name="last_visit", type="string", nullable=true)
  109.      */
  110.     private $last_logs;
  111.    
  112.    
  113.     /**
  114.      * Set record identity
  115.      *
  116.      * @param integer $id
  117.      */
  118.     public function setId( $id )
  119.     {
  120.         $this->id = $id;
  121.     }
  122.  
  123.     /**
  124.      * Get id
  125.      *
  126.      * @return integer
  127.      */
  128.     public function getId()
  129.     {
  130.         return $this->id;
  131.     }
  132.  
  133.     /**
  134.      * Set username
  135.      *
  136.      * @param string $username
  137.      */
  138.     public function setUsername($username)
  139.     {
  140.         $this->username = $username;
  141.     }
  142.  
  143.     /**
  144.      * Get username
  145.      *
  146.      * @return string
  147.      */
  148.     public function getUsername()
  149.     {
  150.         return $this->username;
  151.     }
  152.  
  153.     /**
  154.      * Set password
  155.      *
  156.      * @param string $password
  157.      */
  158.     public function setPassword($password)
  159.     {
  160.         $this->password = $password;
  161.     }
  162.  
  163.     /**
  164.      * Get password
  165.      *
  166.      * @return string
  167.      */
  168.     public function getPassword()
  169.     {
  170.         return $this->password;
  171.     }
  172.    
  173.    
  174.     public function setPlainTextPassword($plainTextPassword)
  175.     {
  176.         $this->plainTextPassword = $plainTextPassword;
  177.     }
  178.    
  179.     /**
  180.      *
  181.      * @return String
  182.      */
  183.     public function getPlainTextPassword()
  184.     {
  185.         return $this->plainTextPassword;
  186.     }
  187.  
  188.     /**
  189.      * Set email
  190.      *
  191.      * @param string $email
  192.      */
  193.     public function setEmail($email)
  194.     {
  195.         $this->email = $email;
  196.     }
  197.  
  198.     /**
  199.      * Get email
  200.      *
  201.      * @return string
  202.      */
  203.     public function getEmail()
  204.     {
  205.         return $this->email;
  206.     }
  207.  
  208.     /**
  209.      * Set role
  210.      *
  211.      * @param integer $role
  212.      */
  213.     public function setRole($role)
  214.     {
  215.         $this->role = $role;
  216.     }
  217.  
  218.     /**
  219.      * Get role
  220.      *
  221.      * @return integer
  222.      */
  223.     public function getRole()
  224.     {
  225.         return $this->role;
  226.     }
  227.  
  228.     /**
  229.      * Set status
  230.      *
  231.      * @param integer $status
  232.      */
  233.     public function setStatus($status)
  234.     {
  235.         $this->status = $status;
  236.     }
  237.  
  238.     /**
  239.      * Get status
  240.      *
  241.      * @return integer
  242.      */
  243.     public function getStatus()
  244.     {
  245.         return $this->status;
  246.     }
  247.  
  248.     /**
  249.      * Set create_date
  250.      *
  251.      * @param datetime $createDate
  252.      */
  253.     public function setCreateDate($createDate)
  254.     {
  255.         $this->create_date = $createDate;
  256.     }
  257.  
  258.     /**
  259.      * Get create_date
  260.      *
  261.      * @return datetime
  262.      */
  263.     public function getCreateDate()
  264.     {
  265.         return $this->create_date;
  266.     }
  267.  
  268.     /**
  269.      * Set creator
  270.      *
  271.      * @param integer $creator
  272.      */
  273.     public function setCreator($creator)
  274.     {
  275.         $this->creator = $creator;
  276.     }
  277.  
  278.     /**
  279.      * Get creator
  280.      *
  281.      * @return integer
  282.      */
  283.     public function getCreator()
  284.     {
  285.         return $this->creator;
  286.     }
  287.  
  288.     /**
  289.      * Set last_update
  290.      *
  291.      * @param datetime $lastUpdate
  292.      */
  293.     public function setLastUpdate($lastUpdate)
  294.     {
  295.         $this->last_update = $lastUpdate;
  296.     }
  297.  
  298.     /**
  299.      * Get last_update
  300.      *
  301.      * @return datetime
  302.      */
  303.     public function getLastUpdate()
  304.     {
  305.         return $this->last_update;
  306.     }
  307.    
  308.     /**
  309.      * Get all available roles
  310.      *
  311.      * @return Array
  312.      */
  313.     public function getRoles()
  314.     {
  315.         return $this->roles;
  316.     }
  317.    
  318.     /**
  319.      * Returns the salt
  320.      *
  321.      * @return String
  322.      */
  323.     public function getSalt()
  324.     {
  325.         return crypt("vcRockz","salt");
  326.     }
  327.    
  328.     /**
  329.      * Removes sensitive data from the user
  330.      *
  331.      * @return void
  332.      */
  333.     public function eraseCredentials()
  334.     {
  335.         $this->setPassword('');
  336.     }
  337.    
  338.     /**
  339.      * Authenticates user
  340.      *
  341.      * @param \Symfony\Component\Security\Core\User\UserInterface $manager
  342.      * @return Boolean
  343.      */
  344.     public function equals(\Symfony\Component\Security\Core\User\UserInterface $manager)
  345.     {
  346.         return $manager->getUsername() === $this->getUsername();
  347.     }
  348.    
  349.     /**
  350.      * @ORM\preUpdate
  351.      */
  352.     public function setLastUpdateValue()
  353.     {
  354.         $this->last_update = new \DateTime();
  355.     }
  356.    
  357.     /**
  358.      * @ORM\prePersist
  359.      */
  360.     public function setCreateDateValue()
  361.     {
  362.         $this->create_date = new \DateTime();
  363.     }
  364.    
  365.  
  366.  
  367.     /**
  368.      * Set last_logs
  369.      *
  370.      * @param string $lastLogs
  371.      */
  372.     public function setLastLogs($lastLogs)
  373.     {
  374.         $this->last_logs = $lastLogs;
  375.     }
  376.  
  377.     /**
  378.      * Get last_logs
  379.      *
  380.      * @return string
  381.      */
  382.     public function getLastLogs()
  383.     {
  384.         return $this->last_logs;
  385.     }
  386. }
Add Comment
Please, Sign In to add comment