Commit 37e28b42 authored by Mat's avatar Mat

entity user, fait à la main

raccourcis pour générer le contrat de l'interface, et les getters/setters
parent 8c5e5fd7
<?php
namespace SocketBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* User
*
* @ORM\Table(name="user")
* @ORM\Entity(repositoryClass="SocketBundle\Repository\UserRepository")
*/
class User implements UserInterface
{
/*
* Note:
*
* <Alt-Enter> -> add method stubs (curseur sur user interface)
* <Alt-Insert> -> en bas de la classe
* + setter et getters
* + getters username et password
* cocher fluent setters: ajoute 'return $this', permet le chainage
*/
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
* @ORM\Column(name="username", type="string", length=255, nullable=false, unique=true)
* @Assert\NotBlank()
*/
private $username;
/**
* @var string
* @ORM\Column(name="email", type="string", length=255, nullable=false, unique=true)
* @Assert\NotBlank()
*/
private $email;
/**
* @var string
* @ORM\Column(name="password", type="string", length=255, nullable=false, unique=false)
*/
private $password;
/**
* @var array
* @ORM\Column(name="role", type="array", length=255, nullable=false, unique=false, options={default: ["ROLE_USER"]})
*/
private $role;
/**
* @var string
* @ORM\Column(name="avatar", type="string", length=255, nullable=true, unique=true)
*/
private $avatar;
/**
* @var UploadedFile
*/
private $file;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Returns the roles granted to the user.
*
* <code>
* public function getRoles()
* {
* return array('ROLE_USER');
* }
* </code>
*
* Alternatively, the roles might be stored on a ``roles`` property,
* and populated in any number of different ways when the user object
* is created.
*
* @return (Role|string)[] The user roles
*/
public function getRoles()
{
return $this->role;
}
/**
* Returns the password used to authenticate the user.
*
* This should be the encoded password. On authentication, a plain-text
* password will be salted, encoded, and then compared to this value.
*
* @return string The password
*/
public function getPassword()
{
return $this->password;
}
/**
* Returns the salt that was originally used to encode the password.
*
* This can return null if the password was not encoded using a salt.
*
* @return string|null The salt
*/
public function getSalt()
{
return null;
}
/**
* Returns the username used to authenticate the user.
*
* @return string The username
*/
public function getUsername()
{
return $this->username;
}
/**
* Removes sensitive data from the user.
*
* This is important if, at any given point, sensitive information like
* the plain-text password is stored on this object.
*/
public function eraseCredentials()
{
$this->password = null;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* @return array
*/
public function getRole()
{
return $this->role;
}
/**
* @param array $role
* @return User
*/
public function setRole($role)
{
$this->role = $role;
return $this;
}
/**
* @return string
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* @param string $avatar
* @return User
*/
public function setAvatar($avatar)
{
$this->avatar = $avatar;
return $this;
}
/**
* @return UploadedFile
*/
public function getFile()
{
return $this->file;
}
/**
* @param UploadedFile $file
* @return User
*/
public function setFile($file)
{
$this->file = $file;
return $this;
}
/**
* @param string $username
* @return User
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* @param string $password
* @return User
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
}
<?php
namespace SocketBundle\Repository;
/**
* UserRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class UserRepository extends \Doctrine\ORM\EntityRepository
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment