Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace MySchool\AdminBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\Security\Core\User\UserInterface as BaseUser;
- /**
- * My\AdminBundle\Entity\User
- *
- * @ORM\Table()
- * @ORM\Entity(repositoryClass="MySchool\AdminBundle\Repository\UserRepository")
- */
- class User implements BaseUser, \Serializable
- {
- /**
- * @var integer $id
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string $name
- *
- * @ORM\Column(name="name", type="string", length=32)
- */
- private $name;
- /**
- * @var string $firstName
- *
- * @ORM\Column(name="firstName", type="string", length=32)
- */
- private $firstName;
- /**
- * @var string $userName
- *
- * @ORM\Column(name="userName", type="string", length=16, unique="TRUE")
- */
- private $userName;
- /**
- * @var string $password
- *
- * @ORM\Column(name="password", type="string", length=64)
- */
- private $password;
- /**
- * @var string $email
- *
- * @ORM\Column(name="email", type="string", length=128, nullable=TRUE)
- */
- private $email;
- /**
- * Get id
- *
- * @return integer $id
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set name
- *
- * @param string $name
- */
- public function setName($name)
- {
- $this->name = $name;
- }
- /**
- * Get name
- *
- * @return string $name
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * Set firstName
- *
- * @param string $firstName
- */
- public function setFirstName($firstName)
- {
- $this->firstName = $firstName;
- }
- /**
- * Get firstName
- *
- * @return string $firstName
- */
- public function getFirstName()
- {
- return $this->firstName;
- }
- /**
- * Set password
- *
- * @param string $password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * Get password
- *
- * @return string $password
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * Set email
- *
- * @param string $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * Get email
- *
- * @return string $email
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * @ORM\OneToMany(targetEntity="MySchool\UserBundle\Entity\Message", mappedBy="user")
- */
- protected $senders;
- /**
- * @ORM\OneToMany(targetEntity="MySchool\UserBundle\Entity\Message", mappedBy="user")
- */
- protected $receivers;
- /**
- * @ORM\OneToOne(targetEntity="Child", mappedBy="user")
- */
- protected $child;
- /**
- * @ORM\OneToOne(targetEntity="Adult", mappedBy="user")
- */
- protected $adult;
- public function __construct()
- {
- $this->senders = new ArrayCollection();
- $this->receivers = new ArrayCollection();
- }
- public function getRoles()
- {
- return array('ROLE_ADMIN');
- }
- public function getSalt()
- {
- return '';
- }
- public function eraseCredentials()
- {
- return '';
- }
- public function equals (BaseUser $user)
- {
- if (!$user instanceof User)
- return FALSE;
- if ($this->password != $user->getPassword())
- return FALSE;
- if ($this->userName != $user->getUsername())
- return FALSE;
- return TRUE;
- }
- /**
- * Add senders
- *
- * @param MySchool\UserBundle\Entity\Message $senders
- */
- public function addSenders(\MySchool\UserBundle\Entity\Message $senders)
- {
- $this->senders[] = $senders;
- }
- /**
- * Get senders
- *
- * @return Doctrine\Common\Collections\Collection $senders
- */
- public function getSenders()
- {
- return $this->senders;
- }
- /**
- * Add receivers
- *
- * @param MySchool\UserBundle\Entity\Message $receivers
- */
- public function addReceivers(\MySchool\UserBundle\Entity\Message $receivers)
- {
- $this->receivers[] = $receivers;
- }
- /**
- * Get receivers
- *
- * @return Doctrine\Common\Collections\Collection $receivers
- */
- public function getReceivers()
- {
- return $this->receivers;
- }
- /**
- * Set child
- *
- * @param MySchool\AdminBundle\Entity\Child $child
- */
- public function setChild(\MySchool\AdminBundle\Entity\Child $child)
- {
- $this->child = $child;
- }
- /**
- * Get child
- *
- * @return MySchool\AdminBundle\Entity\Child $child
- */
- public function getChild()
- {
- return $this->child;
- }
- /**
- * Set adult
- *
- * @param MySchool\AdminBundle\Entity\Adult $adult
- */
- public function setAdult(\MySchool\AdminBundle\Entity\Adult $adult)
- {
- $this->adult = $adult;
- }
- /**
- * Get adult
- *
- * @return MySchool\AdminBundle\Entity\Adult $adult
- */
- public function getAdult()
- {
- return $this->adult;
- }
- /**
- * Set userName
- *
- * @param string $userName
- */
- public function setUserName()
- {
- $this->userName = strtolower(substr($this->name, 0, 6) . '_' . substr($this->firstName, 0, 1));
- }
- /**
- * Get userName
- *
- * @return string $userName
- */
- public function getUserName()
- {
- return $this->userName;
- }
- /**
- * Get name & firstName
- *
- * @return string $nameFirstName
- */
- public function getNameFirstName()
- {
- return $this->name . ' ' . $this->firstName;
- }
- public function serialize() {
- $data = array(
- 'id' => $this->id,
- 'userName' => $this->userName,
- 'email' => $this->email,
- 'password' => $this->password,
- 'name' => $this->name,
- 'firstName' => $this->firstName,
- );
- }
- public function unserialize($serialized)
- {
- $data = unserialize($serialized);
- $this->id = $data['id'];
- $this->userName = $data['userName'];
- $this->email = $data['email'];
- $this->password = $data['password'];
- $this->name = $data['name'];
- $this->firstName = $data['firstName'];
- }
- }
Add Comment
Please, Sign In to add comment