Advertisement
Guest User

Untitled

a guest
Sep 6th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.47 KB | None | 0 0
  1. <?php
  2.  
  3. namespace WebAwardsBundle\Entity;
  4.  
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Serializer\Serializer;
  8. use Doctrine\ORM\Mapping as ORM;
  9.  
  10. /**
  11.  * User
  12.  *
  13.  * @ORM\Table(name="user")
  14.  * @ORM\Entity(repositoryClass="WebAwardsBundle\Repository\UserRepository")
  15.  */
  16. class User implements UserInterface, \Serializable
  17. {
  18.     /**
  19.      * @var int
  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
  29.      *
  30.      * @ORM\Column(name="firstname", type="string", length=125)
  31.      * @Assert\NotBlank()
  32.      */
  33.     private $firstname;
  34.  
  35.     /**
  36.      * @var string
  37.      *
  38.      * @ORM\Column(name="lastname", type="string", length=125)
  39.      * @Assert\NotBlank()
  40.      */
  41.     private $lastname;
  42.  
  43.     /**
  44.      * @var \DateTime
  45.      *
  46.      * @ORM\Column(name="birthdayAt", type="datetime")
  47.      * @Assert\NotBlank()
  48.      */
  49.     private $birthdayAt;
  50.  
  51.     /**
  52.      * @Assert\NotBlank()
  53.      * @Assert\Length(max=4096)
  54.      */
  55.     private $plainPassword;
  56.  
  57.     /**
  58.      * @var string
  59.      *
  60.      * @ORM\Column(name="password", type="string", length=255)
  61.      */
  62.     private $password;
  63.  
  64.     /**
  65.      * @var string
  66.      *
  67.      * @ORM\Column(name="email", type="string", length=125)
  68.      * @Assert\NotBlank()
  69.      */
  70.     private $email;
  71.  
  72.     /**
  73.      * @var string
  74.      *
  75.      * @ORM\Column(name="img", type="string", length=125)
  76.      */
  77.     private $img;
  78.  
  79.     /**
  80.      * @var string
  81.      *
  82.      * @ORM\Column(name="role", type="string", length=40)
  83.      */
  84.     private $role;
  85.  
  86.     /**
  87.      * @var bool
  88.      *
  89.      * @ORM\Column(name="isPublisher", type="boolean")
  90.      */
  91.     private $isPublisher;
  92.  
  93.     /**
  94.      * @var bool
  95.      *
  96.      * @ORM\Column(name="isSubscribe", type="boolean")
  97.      */
  98.     private $isSubscribe;
  99.  
  100.     /**
  101.      * @var bool
  102.      *
  103.      * @ORM\Column(name="isAdmin", type="boolean")
  104.      */
  105.     private $isAdmin;
  106.  
  107.     /**
  108.      * @var \DateTime
  109.      *
  110.      * @ORM\Column(name="dateAff", type="datetime")
  111.      */
  112.     private $dateAff;
  113.  
  114.  
  115.     /**
  116.      * @ORM\OneToMany(targetEntity="Comment", mappedBy="idUser")
  117.      */
  118.     private $idUsers;
  119.    
  120.     /**
  121.      * @ORM\OneToMany(targetEntity="Vote", mappedBy="idUser")
  122.      */
  123.     private $votes;
  124.  
  125.     /**
  126.      * @ORM\OneToMany(targetEntity="Project", mappedBy="idAuthor")
  127.      */
  128.     private $projects;
  129.  
  130.     /**
  131.      * @ORM\Column(name="is_active", type="boolean")
  132.      */
  133.     private $isActive;
  134.  
  135.     /**
  136.      * @ORM\Column(type="string", length=25, unique=true)
  137.      */
  138.     private $username;
  139.     /**
  140.      * Get id
  141.      *
  142.      * @return int
  143.      */
  144.     public function getId()
  145.     {
  146.         return $this->id;
  147.     }
  148.  
  149.     /**
  150.      * Set firstname
  151.      *
  152.      * @param string $firstname
  153.      *
  154.      * @return User
  155.      */
  156.     public function setFirstname($firstname)
  157.     {
  158.         $this->firstname = $firstname;
  159.  
  160.         return $this;
  161.     }
  162.  
  163.     /**
  164.      * Get firstname
  165.      *
  166.      * @return string
  167.      */
  168.     public function getFirstname()
  169.     {
  170.         return $this->firstname;
  171.     }
  172.  
  173.     /**
  174.      * Set lastname
  175.      *
  176.      * @param string $lastname
  177.      *
  178.      * @return User
  179.      */
  180.     public function setLastname($lastname)
  181.     {
  182.         $this->lastname = $lastname;
  183.  
  184.         return $this;
  185.     }
  186.  
  187.     /**
  188.      * Get lastname
  189.      *
  190.      * @return string
  191.      */
  192.     public function getLastname()
  193.     {
  194.         return $this->lastname;
  195.     }
  196.  
  197.     /**
  198.      * Set birthdayAt
  199.      *
  200.      * @param \DateTime $birthdayAt
  201.      *
  202.      * @return User
  203.      */
  204.     public function setBirthdayAt($birthdayAt)
  205.     {
  206.         $this->birthdayAt = $birthdayAt;
  207.  
  208.         return $this;
  209.     }
  210.  
  211.     /**
  212.      * Get birthdayAt
  213.      *
  214.      * @return \DateTime
  215.      */
  216.     public function getBirthdayAt()
  217.     {
  218.         return $this->birthdayAt;
  219.     }
  220.  
  221.     /**
  222.      * Set password
  223.      *
  224.      * @param string $password
  225.      *
  226.      * @return User
  227.      */
  228.     public function setPassword($password)
  229.     {
  230.         $this->password = $password;
  231.  
  232.         return $this;
  233.     }
  234.    
  235.  
  236.     /**
  237.      * Set email
  238.      *
  239.      * @param string $email
  240.      *
  241.      * @return User
  242.      */
  243.     public function setEmail($email)
  244.     {
  245.         $this->email = $email;
  246.  
  247.         return $this;
  248.     }
  249.  
  250.     /**
  251.      * Get email
  252.      *
  253.      * @return string
  254.      */
  255.     public function getEmail()
  256.     {
  257.         return $this->email;
  258.     }
  259.  
  260.     /**
  261.      * Set img
  262.      *
  263.      * @param string $img
  264.      *
  265.      * @return User
  266.      */
  267.     public function setImg($img)
  268.     {
  269.         $this->img = $img;
  270.  
  271.         return $this;
  272.     }
  273.  
  274.     /**
  275.      * Get img
  276.      *
  277.      * @return string
  278.      */
  279.     public function getImg()
  280.     {
  281.         return $this->img;
  282.     }
  283.  
  284.     /**
  285.      * Set role
  286.      *
  287.      * @param string $role
  288.      *
  289.      * @return User
  290.      */
  291.     public function setRole($role)
  292.     {
  293.         $this->role = $role;
  294.  
  295.         return $this;
  296.     }
  297.  
  298.  
  299.     /**
  300.      * Get role
  301.      *
  302.      * @return string
  303.      */
  304.     public function getRole()
  305.     {
  306.         return $this->role;
  307.     }
  308.  
  309.     /**
  310.      * Set isPublisher
  311.      *
  312.      * @param boolean $isPublisher
  313.      *
  314.      * @return User
  315.      */
  316.     public function setIsPublisher($isPublisher)
  317.     {
  318.         $this->isPublisher = $isPublisher;
  319.  
  320.         return $this;
  321.     }
  322.  
  323.     /**
  324.      * Get isPublisher
  325.      *
  326.      * @return bool
  327.      */
  328.     public function getIsPublisher()
  329.     {
  330.         return $this->isPublisher;
  331.     }
  332.  
  333.     /**
  334.      * Set isSubscribe
  335.      *
  336.      * @param boolean $isSubscribe
  337.      *
  338.      * @return User
  339.      */
  340.     public function setIsSubscribe($isSubscribe)
  341.     {
  342.         $this->isSubscribe = $isSubscribe;
  343.  
  344.         return $this;
  345.     }
  346.  
  347.     /**
  348.      * Get isSubscribe
  349.      *
  350.      * @return bool
  351.      */
  352.     public function getIsSubscribe()
  353.     {
  354.         return $this->isSubscribe;
  355.     }
  356.  
  357.     /**
  358.      * Set isAdmin
  359.      *
  360.      * @param boolean $isAdmin
  361.      *
  362.      * @return User
  363.      */
  364.     public function setIsAdmin($isAdmin)
  365.     {
  366.         $this->isAdmin = $isAdmin;
  367.  
  368.         return $this;
  369.     }
  370.  
  371.     /**
  372.      * Get isAdmin
  373.      *
  374.      * @return bool
  375.      */
  376.     public function getIsAdmin()
  377.     {
  378.         return $this->isAdmin;
  379.     }
  380.  
  381.     /**
  382.      * Set dateAff
  383.      *
  384.      * @param \DateTime $dateAff
  385.      *
  386.      * @return User
  387.      */
  388.     public function setDateAff($dateAff)
  389.     {
  390.         $this->dateAff = new \DateTime($dateAff);
  391.  
  392.         return $this;
  393.     }
  394.  
  395.     /**
  396.      * Get dateAff
  397.      *
  398.      * @return \DateTime
  399.      */
  400.     public function getDateAff()
  401.     {
  402.         return $this->dateAff;
  403.     }
  404.  
  405.  
  406.     public function __construct()
  407.     {
  408.         $this->isActive = true;
  409.         // may not be needed, see section on salt below
  410.         // $this->salt = md5(uniqid(null, true));
  411.     }
  412.  
  413.     public function getUsername()
  414.     {
  415.         return $this->username;
  416.     }
  417.     public function setUsername($username)
  418.     {
  419.         $this->username = $username;
  420.  
  421.         return $this;
  422.     }
  423.  
  424.     public function __toString()
  425.     {
  426.         return "".$this->getId();
  427.     }
  428.     public function getSalt()
  429.     {
  430.         // you *may* need a real salt depending on your encoder
  431.         // see section on salt below
  432.         return null;
  433.     }
  434.  
  435.     public function getPassword()
  436.     {
  437.         return $this->password;
  438.     }
  439.  
  440.     public function getRoles()
  441.     {
  442.         return array('ROLE_USER');
  443.     }
  444.  
  445.     public function eraseCredentials()
  446.     {
  447.     }
  448.  
  449.     /** @see \Serializable::serialize() */
  450.     public function serialize()
  451.     {
  452.         return serialize(array(
  453.             $this->id,
  454.             $this->username,
  455.             $this->password,
  456.             // see section on salt below
  457.             // $this->salt,
  458.         ));
  459.     }
  460.  
  461.     /** @see \Serializable::unserialize() */
  462.     public function unserialize($serialized)
  463.     {
  464.         list (
  465.             $this->id,
  466.             $this->username,
  467.             $this->password,
  468.             // see section on salt below
  469.             // $this->salt
  470.             ) = unserialize($serialized);
  471.     }
  472.     public function getPlainPassword()
  473.     {
  474.         return $this->plainPassword;
  475.     }
  476.  
  477.     public function setPlainPassword($password)
  478.     {
  479.         $this->plainPassword = $password;
  480.     }
  481.  
  482.  
  483. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement