Skip to content

Instantly share code, notes, and snippets.

@hugoleodev
Created July 11, 2012 16:23
Show Gist options
  • Save hugoleodev/3091530 to your computer and use it in GitHub Desktop.
Save hugoleodev/3091530 to your computer and use it in GitHub Desktop.
User
<?php
namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\Common\Collections\ArrayCollection;
/**
* User
* @ORM\Entity
* @author Administrator
*/
class User
{
const STATUS_WAITING_CONFIRMATION = 2;
const STATUS_ACTIVE = 1;
const STATUS_INACTIVE = 0;
const STATUS_BLOCKED = 3;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer", name="user_id")
*/
protected $id;
/**
*
*/
protected $roleId;
/**
* @ORM\Column(type="string")
*/
protected $email;
/**
* @ORM\Column(type="string")
*/
protected $pass;
/**
* @ORM\Column(type="string", name="confirmation_code")
*/
protected $confirmationCode;
/**
* @ORM\Column(type="integer")
*/
protected $status;
/**
* @ORM\Column(type="string")
*/
protected $name;
/**
* @ORM\Column(type="string")
*/
protected $bio;
/**
* @ORM\Column(type="datetime", name="created_at")
*/
protected $createdAt;
/**
* @ORM\Column(type="datetime", name="updated_at")
*/
protected $updatedAt;
/**
* @ORM\ManyToMany(targetEntity="Role")
* @ORM\JoinTable(name="user_role",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="user_id")},
* inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="role_id")}
* )
*/
protected $roles;
public function __construct()
{
$this->roles = new ArrayCollection();
$this->createdAt = $this->updatedAt = new \DateTime;
}
public function getId()
{
return $this->id;
}
public function getRoleId()
{
return $this->roleId;
}
public function setRoleId($roleId)
{
$this->roleId = $roleId;
}
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getPass()
{
return $this->pass;
}
public function setPass($pass)
{
$this->pass = sha1($pass);
}
public function getConfirmationCode()
{
return $this->confirmationCode;
}
public function setConfirmationCode($confirmationCode)
{
$this->confirmationCode = $confirmationCode;
}
public function getStatus()
{
return $this->status;
}
public function setStatus($status)
{
$this->status = $status;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getBio()
{
return $this->bio;
}
public function setBio($bio)
{
$this->bio = $bio;
}
public function getCreatedAt()
{
return $this->createdAt;
}
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @ORM\PrePersist
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = new \DateTime;
}
public function addRole(Role $role)
{
$this->roles->add($role);
}
public function getRoles()
{
return $this->roles;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment