SHARE
TWEET

User

a guest Dec 24th, 2017 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace SoftUniBlogBundle\Entity;
  4.  
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8.  
  9. /**
  10.  * User
  11.  *
  12.  * @ORM\Table(name="users")
  13.  * @ORM\Entity(repositoryClass="SoftUniBlogBundle/Repository/UserRepository")
  14.  */
  15. class User implements UserInterface
  16. {
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.  
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="email", type="string", length=100, unique=true)
  30.      */
  31.     private $email;
  32.  
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="fullName", type="string", length=255)
  37.      */
  38.     private $fullName;
  39.  
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="password", type="string", length=255)
  44.      */
  45.     private $password;
  46.  
  47.     /**
  48.      * @var ArrayCollection
  49.      *
  50.      * @ORM\OneToMany(targetEntity="SotUniBlogBundle\Entity\Article", mappedBy="author")
  51.      */
  52.     private $articles;
  53.  
  54.     /**
  55.      * @return \Doctrine\Common\Collections\Collection
  56.      */
  57.     public function getArticles()
  58.     {
  59.         return $this->articles;
  60.     }
  61.  
  62.     /**
  63.      * @param \SoftUniBlogBundle\Entity\Article $article
  64.      *
  65.      * @return User
  66.      */
  67.     public function addPost(Article $article)
  68.     {
  69.         $this->articles[] = $article;
  70.  
  71.         return $this;
  72.     }
  73.  
  74.     /**
  75.      * Get id
  76.      *
  77.      * @return int
  78.      */
  79.     public function getId()
  80.     {
  81.         return $this->id;
  82.     }
  83.  
  84.     /**
  85.      * Set email
  86.      *
  87.      * @param string $email
  88.      *
  89.      * @return User
  90.      */
  91.     public function setEmail($email)
  92.     {
  93.         $this->email = $email;
  94.  
  95.         return $this;
  96.     }
  97.  
  98.     /**
  99.      * Get email
  100.      *
  101.      * @return string
  102.      */
  103.     public function getEmail()
  104.     {
  105.         return $this->email;
  106.     }
  107.  
  108.     /**
  109.      * Set fullName
  110.      *
  111.      * @param string $fullName
  112.      *
  113.      * @return User
  114.      */
  115.     public function setFullName($fullName)
  116.     {
  117.         $this->fullName = $fullName;
  118.  
  119.         return $this;
  120.     }
  121.  
  122.     /**
  123.      * Get fullName
  124.      *
  125.      * @return string
  126.      */
  127.     public function getFullName()
  128.     {
  129.         return $this->fullName;
  130.     }
  131.  
  132.     /**
  133.      * Set password
  134.      *
  135.      * @param string $password
  136.      *
  137.      * @return User
  138.      */
  139.     public function setPassword($password)
  140.     {
  141.         $this->password = $password;
  142.  
  143.         return $this;
  144.     }
  145.  
  146.     /**
  147.      * Get password
  148.      *
  149.      * @return string
  150.      */
  151.     public function getPassword()
  152.     {
  153.         return $this->password;
  154.     }
  155.  
  156.     /**
  157.      * Returns the roles granted to the user.
  158.      *
  159.      * <code>
  160.      * public function getRoles()
  161.      * {
  162.      *     return array('ROLE_USER');
  163.      * }
  164.      * </code>
  165.      *
  166.      * Alternatively, the roles might be stored on a ``roles`` property,
  167.      * and populated in any number of different ways when the user object
  168.      * is created.
  169.      *
  170.      * @return (Role|string)[] The user roles
  171.      */
  172.     public function getRoles()
  173.     {
  174.         return ['ROLE_USER'];
  175.     }
  176.  
  177.     /**
  178.      * Returns the salt that was originally used to encode the password.
  179.      *
  180.      * This can return null if the password was not encoded using a salt.
  181.      *
  182.      * @return string|null The salt
  183.      */
  184.     public function getSalt()
  185.     {
  186.         return null;
  187.     }
  188.  
  189.     /**
  190.      * Returns the username used to authenticate the user.
  191.      *
  192.      * @return string The username
  193.      */
  194.     public function getUsername()
  195.     {
  196.         return $this->email;
  197.     }
  198.  
  199.     /**
  200.      * Removes sensitive data from the user.
  201.      *
  202.      * This is important if, at any given point, sensitive information like
  203.      * the plain-text password is stored on this object.
  204.      */
  205.     public function eraseCredentials()
  206.     {
  207.         // TODO: Implement eraseCredentials() method.
  208.     }
  209.  
  210.     function __toString()
  211.     {
  212.         return $this->fullName;
  213.     }
  214.  
  215.     public function __construct()
  216.     {
  217.         $this->articles = new ArrayCollection();
  218.     }
  219. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top