Advertisement
Guest User

Untitled

a guest
Jan 15th, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.86 KB | None | 0 0
  1. <?php
  2. namespace App\Entity;
  3.  
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use App\Repository\UserRepository;
  9. use Elastica\Search;
  10.  
  11. /**
  12.  * @UniqueEntity(fields="email", message="Email already taken")
  13.  * @UniqueEntity(fields="username", message="Username already taken")
  14.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  15.  * @Search(repositoryClass="AppBundle\SearchRepository\PropositionRepository")
  16.  */
  17. class User implements UserInterface
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\Column(type="integer")
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.  
  26.     /**
  27.      * @var Post
  28.      * @ORM\OneToMany(targetEntity="Post", mappedBy="id")
  29.      */
  30.     private $post;
  31.  
  32.     /**
  33.      * @var Points
  34.      * @ORM\OneToMany(targetEntity="Points", mappedBy="id")
  35.      */
  36.     private $points;
  37.  
  38.     /**
  39.      * @var Comments
  40.      * @ORM\OneToMany(targetEntity="Comments", mappedBy="user")
  41.      */
  42.     private $comments;
  43.  
  44.     /**
  45.      * @ORM\Column(type="string", length=255, unique=true)
  46.      * @Assert\NotBlank()
  47.      * @Assert\Email()
  48.      */
  49.     private $email;
  50.  
  51.     /**
  52.      * @ORM\Column(type="string", length=50, unique=true)
  53.      * @Assert\NotBlank()
  54.      * @Assert\Length(
  55.      *      min = 4,
  56.      *      max = 50,
  57.      *      minMessage = "Your username must be at least {{ limit }} characters long",
  58.      *      maxMessage = "Your username cannot be longer than {{ limit }} characters"
  59.      * )
  60.      * @Assert\Regex(
  61.      *      pattern = "/^[a-z0-9][a-z0-9_\-]+$/i",
  62.      *      htmlPattern = "^[a-z]+$",
  63.      *      message = "The login may contain uppercase and lowercase letters, numbers, and - and _ characters, but must begin with a letter or number."
  64.      * )
  65.      */
  66.     private $username;
  67.  
  68.     /**
  69.      * @Assert\NotBlank()
  70.     //     * @Assert\Length(max=4096)
  71.      * @Assert\Length(
  72.      *      min = 4,
  73.      *      max = 80,
  74.      *      minMessage = "Your password must be at least {{ limit }} characters long",
  75.      *      maxMessage = "Your password cannot be longer than {{ limit }} characters"
  76.      * )
  77.      */
  78.     private $plainPassword;
  79.  
  80.     /**
  81.      * The below length depends on the "algorithm" you use for encoding
  82.      * the password, but this works well with bcrypt.
  83.      *
  84.      * @ORM\Column(type="string", length=64)
  85.      */
  86.     private $password;
  87.  
  88.  
  89.     /**
  90.      * @ORM\Column(type="array")
  91.      */
  92.     private $roles;
  93.  
  94.     /**
  95.      * @ORM\Column(type="datetime", nullable=true)
  96.      */
  97.     private $creationdatetime;
  98.  
  99.     /**
  100.      * @ORM\Column(type="integer", nullable=true)
  101.      */
  102.     private $visibility;
  103.  
  104.     /**
  105.      * @ORM\Column(type="string", nullable=true)
  106.      * @Assert\File(
  107.      *     mimeTypes={ "image/x-png,image/gif,image/jpeg" },
  108.      *     mimeTypesMessage="Invalid image!",
  109.      *     maxSize="1024k",
  110.      *     maxSizeMessage="The maximum file size is 1 MB"
  111.      * )
  112.      */
  113.     private $avatar;
  114.  
  115.     /**
  116.      * @ORM\Column(type="boolean", nullable=true, options={"default" : 0})
  117.      */
  118.     private $verified;
  119.  
  120.     /**
  121.      * @ORM\Column(type="string", length=255, nullable=true)
  122.      */
  123.     private $description;
  124.  
  125.     public function __construct()
  126.     {
  127.         $this->roles = array('ROLE_USER');
  128.     }
  129.  
  130.     // other properties and methods
  131.  
  132.     public function getId()
  133.     {
  134.         return $this->id;
  135.     }
  136.  
  137.     public function getEmail()
  138.     {
  139.         return $this->email;
  140.     }
  141.  
  142.     public function setEmail($email)
  143.     {
  144.         $this->email = $email;
  145.     }
  146.  
  147.     public function getUsername()
  148.     {
  149.         return $this->username;
  150.     }
  151.  
  152.     public function setUsername($username)
  153.     {
  154.         $this->username = $username;
  155.     }
  156.  
  157.     public function getPlainPassword()
  158.     {
  159.         return $this->plainPassword;
  160.     }
  161.  
  162.     public function setPlainPassword($password)
  163.     {
  164.         $this->plainPassword = $password;
  165.     }
  166.  
  167.     public function getPassword()
  168.     {
  169.         return $this->password;
  170.     }
  171.  
  172.     public function setPassword($password)
  173.     {
  174.         $this->password = $password;
  175.     }
  176.  
  177.     public function getSalt()
  178.     {
  179.         // The bcrypt and argon2i algorithms don't require a separate salt.
  180.         // You *may* need a real salt if you choose a different encoder.
  181.         return null;
  182.     }
  183.  
  184.     public function getRoles()
  185.     {
  186.         return $this->roles;
  187.     }
  188.  
  189.  
  190.     public function eraseCredentials()
  191.     {
  192.     }
  193.  
  194.     public function getCreationdatetime(): ?\DateTimeInterface
  195.     {
  196.         return $this->creationdatetime;
  197.     }
  198.  
  199.     public function setCreationdatetime(?\DateTimeInterface $creationdatetime): self
  200.     {
  201.         $this->creationdatetime = $creationdatetime;
  202.  
  203.         return $this;
  204.     }
  205.  
  206.     public function getVisibility(): ?int
  207.     {
  208.         return $this->visibility;
  209.     }
  210.  
  211.     public function setVisibility(?int $visibility): self
  212.     {
  213.         $this->visibility = $visibility;
  214.  
  215.         return $this;
  216.     }
  217.  
  218.     public function getAvatar()
  219.     {
  220.         return $this->avatar;
  221.     }
  222.  
  223.     public function setAvatar($avatar)
  224.     {
  225.         $this->avatar = $avatar;
  226.  
  227.         return $this;
  228.     }
  229.  
  230.     public function setRoles(array $roles): self
  231.     {
  232.         $this->roles = $roles;
  233.  
  234.         return $this;
  235.     }
  236.  
  237.     public function getVerified(): ?bool
  238.     {
  239.         return $this->verified;
  240.     }
  241.  
  242.     public function setVerified(?bool $verified): self
  243.     {
  244.         $this->verified = $verified;
  245.  
  246.         return $this;
  247.     }
  248.  
  249.     public function getDescription(): ?string
  250.     {
  251.         return $this->description;
  252.     }
  253.  
  254.     public function setDescription(?string $description): self
  255.     {
  256.         $this->description = $description;
  257.  
  258.         return $this;
  259.     }
  260. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement