Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace RFC\UserBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use FOS\UserBundle\Model\User as BaseUser;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Gedmo\Timestampable\Traits\TimestampableEntity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * User
- *
- * @ORM\Table()
- * @ORM\Entity
- * @UniqueEntity("favoriteNumber", message="user.fav_number.not_unique", ignoreNull=true)
- */
- class User extends BaseUser
- {
- /**
- * Hook timestampable behavior
- * updates createdAt, updatedAt fields
- */
- use TimestampableEntity;
- /**
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORM\Column(name="firstName", type="string", length=255, nullable=true)
- */
- protected $firstName;
- /**
- * @ORM\Column(name="lastName", type="string", length=255, nullable=true)
- */
- protected $lastName;
- /**
- * @ORM\Column(name="age", type="integer", nullable=true)
- */
- protected $age;
- /**
- * @ORM\Column(name="avatarUrl", type="string", length=255, nullable=true)
- */
- protected $avatarUrl;
- /**
- * @ORM\Column(name="favoriteNumber", type="integer", nullable=true, unique=true)
- * @Assert\GreaterThan( value = 0, message="constraint.positive" )
- *
- */
- protected $favoriteNumber;
- /**
- * @ORM\Column(name="locale", type="string", length=5)
- *
- */
- protected $locale;
- public function __construct()
- {
- parent::__construct();
- }
- public function eraseCredentials()
- {
- }
- /**
- * Set firstName
- *
- * @param string $firstName
- * @return User
- */
- public function setFirstName($firstName)
- {
- $this->firstName = $firstName;
- return $this;
- }
- /**
- * Get firstName
- *
- * @return string
- */
- public function getFirstName()
- {
- return $this->firstName;
- }
- /**
- * Set lastName
- *
- * @param string $lastName
- * @return User
- */
- public function setLastName($lastName)
- {
- $this->lastName = $lastName;
- return $this;
- }
- /**
- * Get lastName
- *
- * @return string
- */
- public function getLastName()
- {
- return $this->lastName;
- }
- /**
- * Set age
- *
- * @param integer $age
- * @return User
- */
- public function setAge($age)
- {
- $this->age = $age;
- return $this;
- }
- /**
- * Get age
- *
- * @return integer
- */
- public function getAge()
- {
- return $this->age;
- }
- /**
- * Set avatarUrl
- *
- * @param string $avatarUrl
- * @return User
- */
- public function setAvatarUrl($avatarUrl)
- {
- $this->avatarUrl = $avatarUrl;
- return $this;
- }
- /**
- * Get avatarUrl
- *
- * @return string
- */
- public function getAvatarUrl()
- {
- return $this->avatarUrl;
- }
- function getFavoriteNumber()
- {
- return $this->favoriteNumber;
- }
- function setFavoriteNumber($favoriteNumber)
- {
- $this->favoriteNumber = $favoriteNumber;
- return $this;
- }
- public function getLocale()
- {
- return $this->locale;
- }
- /**
- * @param string $locale
- */
- public function setLocale($locale)
- {
- $this->locale = $locale;
- }
- public function isRoleAdmin()
- {
- return $this->hasRole('ROLE_ADMIN');
- }
- public function isRoleCertifiedManager()
- {
- return $this->hasRole('ROLE_CERTIFIED_MANAGER');
- }
- public function isRoleManager()
- {
- return $this->hasRole('ROLE_MANAGER');
- }
- public function isRoleUser()
- {
- return $this->hasRole('ROLE_USER');
- }
- public function getHighestRole()
- {
- $role = 'ROLE_BANNED';
- if ($this->isRoleUser()) {
- $role = 'ROLE_USER';
- }
- if ($this->isRoleManager()) {
- $role = 'ROLE_MANAGER';
- }
- if ($this->isRoleCertifiedManager()) {
- $role = 'ROLE_CERTIFIED_MANAGER';
- }
- if ($this->isRoleAdmin()) {
- $role = 'ROLE_ADMIN';
- }
- return $role;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement