Advertisement
Guest User

Untitled

a guest
Jan 15th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.08 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Maciek
  5.  * Date: 29.12.2016
  6.  * Time: 18:16
  7.  */
  8.  
  9. namespace AppBundle\Entity;
  10.  
  11.  
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Symfony\Component\Security\Core\User\UserInterface;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17.  
  18. /**
  19.  * @ORM\Entity
  20.  * @ORM\Table(name="user")
  21.  * @UniqueEntity(fields={"email"}, message="Podany email jest już w zajety")
  22.  */
  23. class User implements UserInterface
  24. {
  25.  
  26.     public function __construct()
  27.     {
  28.         $this->restaurants = new ArrayCollection();
  29.     }
  30.  
  31.     /**
  32.      * @ORM\Id
  33.      * @ORM\GeneratedValue(strategy="AUTO")
  34.      * @ORM\Column(type="integer")
  35.      */
  36.     private $id;
  37.  
  38.     /**
  39.      * @Assert\NotBlank()
  40.      * @Assert\Email()
  41.      * @ORM\Column(type="string", unique=true)
  42.      */
  43.     private $email;
  44.  
  45.     /**
  46.      * @Assert\NotBlank(groups={"Registration"})
  47.      * @ORM\Column(type="string")
  48.      */
  49.     private $name;
  50.  
  51.     /**
  52.      * @Assert\NotBlank(groups={"Registration"})
  53.      * @ORM\Column(type="string")
  54.      */
  55.     private $surname;
  56.  
  57.     /**
  58.      * @ORM\Column(type="string")
  59.      */
  60.     private $password;
  61.  
  62.     /**
  63.      * @Assert\NotBlank(message="Podaj hasło", groups={"Registration"})
  64.      */
  65.     private $plainPassword;
  66.  
  67.     /**
  68.      * @ORM\Column(type="json_array")
  69.      */
  70.     private $roles = [];
  71.  
  72.  
  73.     /**
  74.      * @ORM\Column(type="string", nullable=true)
  75.      * @Assert\Image(
  76.      *     minWidth="128",
  77.      *     minHeight="128",
  78.      *     mimeTypes={"image/jpeg", "image/gif", "image/png", "image/jpg"}
  79.      * )
  80.      */
  81.     private $avatar;
  82.  
  83.     /**
  84.      * @ORM\OneToMany(targetEntity="AppBundle\Entity\Restaurant", mappedBy="owner")
  85.      */
  86.     private $restaurants;
  87.  
  88.     public function getUsername()
  89.     {
  90.         return $this->email;
  91.     }
  92.  
  93.     public function getRoles()
  94.     {
  95.         $roles = $this->roles;
  96.  
  97.         if (!in_array('ROLE_USER', $roles)){
  98.             $roles[] = 'ROLE_USER';
  99.         }
  100.  
  101.         return $roles;
  102.     }
  103.  
  104.     /**
  105.      * @param mixed $roles
  106.      */
  107.     public function setRoles(array $roles)
  108.     {
  109.         $this->roles = $roles;
  110.     }
  111.  
  112.     public function getPassword()
  113.     {
  114.         return $this->password;
  115.     }
  116.  
  117.     public function getSalt()
  118.     {
  119.  
  120.     }
  121.  
  122.     public function eraseCredentials()
  123.     {
  124.         $this->plainPassword = null;
  125.     }
  126.  
  127.     public function setEmail($email)
  128.     {
  129.         $this->email = $email;
  130.     }
  131.  
  132.     public function getEmail()
  133.     {
  134.         return $this->email;
  135.     }
  136.  
  137.     /**
  138.      * @param mixed $password
  139.      */
  140.     public function setPassword($password)
  141.     {
  142.         $this->password = $password;
  143.     }
  144.  
  145.     /**
  146.      * @return mixed
  147.      */
  148.     public function getPlainPassword()
  149.     {
  150.         return $this->plainPassword;
  151.     }
  152.  
  153.     /**
  154.      * @param mixed $plainPassword
  155.      */
  156.     public function setPlainPassword($plainPassword)
  157.     {
  158.         $this->plainPassword = $plainPassword;
  159.         $this->password = null;
  160.     }
  161.     /**
  162.      * @return mixed
  163.      */
  164.     public function getName()
  165.     {
  166.         return $this->name;
  167.     }/**
  168.      * @param mixed $name
  169.      */
  170.     public function setName($name)
  171.     {
  172.         $this->name = $name;
  173.     }/**
  174.      * @return mixed
  175.      */
  176.     public function getSurname()
  177.     {
  178.         return $this->surname;
  179.     }/**
  180.      * @param mixed $surname
  181.      */
  182.     public function setSurname($surname)
  183.     {
  184.         $this->surname = $surname;
  185.     }
  186.  
  187.     /**
  188.      * @return mixed
  189.      */
  190.     public function getId()
  191.     {
  192.         return $this->id;
  193.     }
  194.  
  195.     /**
  196.      * @return ArrayCollection|User
  197.      */
  198.     public function getRestaurants()
  199.     {
  200.         return $this->restaurants;
  201.     }
  202.  
  203.     /**
  204.      * @return mixed
  205.      */
  206.     public function getAvatar()
  207.     {
  208.         return $this->avatar;
  209.     }
  210.  
  211.     /**
  212.      * @param mixed $avatar
  213.      */
  214.     public function setAvatar($avatar)
  215.     {
  216.         $this->avatar = $avatar;
  217.     }
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement