Created
June 12, 2015 07:31
-
-
Save albertogviana/cb9c88bc37d0de70d007 to your computer and use it in GitHub Desktop.
User.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace User\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use ZfcUser\Entity\UserInterface; | |
use Rbac\Identity\IdentityInterface; | |
use Doctrine\Common\Collections\ArrayCollection; | |
/** | |
* User | |
* | |
* @ORM\Table(name="security.user") | |
* @ORM\Entity(repositoryClass="User\Repository\User") | |
*/ | |
class User implements UserInterface, IdentityInterface | |
{ | |
/** | |
* @var integer | |
* | |
* @ORM\Column(name="user_id", type="integer", nullable=false) | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="IDENTITY") | |
*/ | |
private $id; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="username", type="string", length=255, nullable=true) | |
*/ | |
private $username; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="email", type="string", length=255, nullable=true) | |
*/ | |
private $email; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="display_name", type="string", length=50, nullable=true) | |
*/ | |
private $displayName; | |
/** | |
* @var string | |
* | |
* @ORM\Column(name="password", type="string", length=128, nullable=false) | |
*/ | |
private $password; | |
/** | |
* @var integer | |
* | |
* @ORM\Column(name="state", type="smallint", nullable=true) | |
*/ | |
private $state; | |
/** | |
* @var \Doctrine\Common\Collections\Collection | |
* | |
* @ORM\OneToMany(targetEntity="User\Entity\UserRoles", mappedBy="user", cascade={"persist","remove"}) | |
*/ | |
private $roles; | |
/** | |
* Initialies the roles variable. | |
*/ | |
public function __construct() | |
{ | |
$this->roles = new ArrayCollection(); | |
} | |
/** | |
* Set username | |
* | |
* @param string $username | |
* @return User | |
*/ | |
public function setUsername($username) | |
{ | |
$this->username = $username; | |
return $this; | |
} | |
/** | |
* Get username | |
* | |
* @return string | |
*/ | |
public function getUsername() | |
{ | |
return $this->username; | |
} | |
/** | |
* Set email | |
* | |
* @param string $email | |
* @return User | |
*/ | |
public function setEmail($email) | |
{ | |
$this->email = $email; | |
return $this; | |
} | |
/** | |
* Get email | |
* | |
* @return string | |
*/ | |
public function getEmail() | |
{ | |
return $this->email; | |
} | |
/** | |
* Set displayName | |
* | |
* @param string $displayName | |
* @return User | |
*/ | |
public function setDisplayName($displayName) | |
{ | |
$this->displayName = $displayName; | |
return $this; | |
} | |
/** | |
* Get displayName | |
* | |
* @return string | |
*/ | |
public function getDisplayName() | |
{ | |
return $this->displayName; | |
} | |
/** | |
* Set password | |
* | |
* @param string $password | |
* @return User | |
*/ | |
public function setPassword($password) | |
{ | |
$this->password = $password; | |
return $this; | |
} | |
/** | |
* Get password | |
* | |
* @return string | |
*/ | |
public function getPassword() | |
{ | |
return $this->password; | |
} | |
/** | |
* Set state | |
* | |
* @param integer $state | |
* @return User | |
*/ | |
public function setState($state) | |
{ | |
$this->state = $state; | |
return $this; | |
} | |
/** | |
* Get state | |
* | |
* @return integer | |
*/ | |
public function getState() | |
{ | |
return $this->state; | |
} | |
/** | |
* Get id. | |
* | |
* @return int | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Set id. | |
* | |
* @param int $id | |
* @return UserInterface | |
*/ | |
public function setId($id) | |
{ | |
$this->id = (int) $id; | |
return $this; | |
} | |
public function getRoles() | |
{ | |
return $this->roles->getValues(); | |
} | |
public function getData() | |
{ | |
return array( | |
'id' => $this->getId(), | |
'username' => $this->getUsername(), | |
'email' => $this->getEmail(), | |
'displayName' => $this->getDisplayName(), | |
'state' => $this->getState(), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment