Advertisement
Guest User

Untitled

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