Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace CMS\SecurityBundle\Entity;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Symfony\Component\Validator\Constraints as Assert;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * CMS\SecurityBundle\Entity\Security
- *
- * @ORM\Table()
- * @ORM\Entity(repositoryClass="CMS\SecurityBundle\Entity\SecurityRepository")
- * @ORM\HasLifecycleCallbacks()
- */
- class Security implements UserInterface
- {
- /**
- * @var integer $id
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string $username
- *
- * @ORM\Column(name="username", type="string", length=255, unique=true)
- * @Assert\MinLength(limit=3, groups={"create"})
- * @Assert\MaxLength(limit=15, groups={"create"})
- */
- private $username;
- /**
- * @var string $password
- *
- * @ORM\Column(name="password", type="string", length=255)
- */
- private $password;
- /**
- * Non encrypted password used for forms
- *
- * @var string $plainTextPassword
- * @Assert\MinLength(limit=5, groups={"create","update"})
- * @Assert\MaxLength(limit=15, groups={"create","update"})
- * @Assert\NotBlank(groups={"create"})
- */
- private $plainTextPassword;
- /**
- * @var string $email
- *
- * @ORM\Column(name="email", type="string", length=255, nullable=true, unique=true)
- * @Assert\Email(groups={"create"})
- */
- private $email;
- /**
- * @var integer $role
- *
- * @ORM\Column(name="role", type="integer")
- * @Assert\NotBlank(groups={"create"})
- * @Assert\Choice( choices = {1,2,3,4} )
- */
- private $role;
- private $roles = array( 1 => 'ROLE_SUPER_ADMIN', 2 => 'ROLE_ADMIN', 3 => 'ROLE_SUPER_MODERATOR', 4 => 'ROLE_MODERATOR' );
- /**
- * @var integer $status
- *
- * @ORM\Column(name="status", type="integer")
- * @Assert\Choice( choices = {1,2} )
- */
- private $status;
- /**
- * @var datetime $create_date
- *
- * @ORM\Column(name="create_date", type="datetime")
- */
- private $create_date;
- /**
- * @var integer $creator
- *
- * @ORM\Column(name="creator", type="integer")
- * @Assert\Type( type="integer" )
- * @Assert\Min( limit=1)
- */
- private $creator;
- /**
- * @var datetime $last_update
- *
- * @ORM\Column(name="last_update", type="datetime", nullable=true)
- */
- private $last_update;
- /**
- * @var type datetime $last_visit
- *
- * @ORM\Column(name="last_visit", type="string", nullable=true)
- */
- private $last_logs;
- /**
- * Set record identity
- *
- * @param integer $id
- */
- public function setId( $id )
- {
- $this->id = $id;
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- */
- public function setUsername($username)
- {
- $this->username = $username;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * Set password
- *
- * @param string $password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * Get password
- *
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- public function setPlainTextPassword($plainTextPassword)
- {
- $this->plainTextPassword = $plainTextPassword;
- }
- /**
- *
- * @return String
- */
- public function getPlainTextPassword()
- {
- return $this->plainTextPassword;
- }
- /**
- * Set email
- *
- * @param string $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set role
- *
- * @param integer $role
- */
- public function setRole($role)
- {
- $this->role = $role;
- }
- /**
- * Get role
- *
- * @return integer
- */
- public function getRole()
- {
- return $this->role;
- }
- /**
- * Set status
- *
- * @param integer $status
- */
- public function setStatus($status)
- {
- $this->status = $status;
- }
- /**
- * Get status
- *
- * @return integer
- */
- public function getStatus()
- {
- return $this->status;
- }
- /**
- * Set create_date
- *
- * @param datetime $createDate
- */
- public function setCreateDate($createDate)
- {
- $this->create_date = $createDate;
- }
- /**
- * Get create_date
- *
- * @return datetime
- */
- public function getCreateDate()
- {
- return $this->create_date;
- }
- /**
- * Set creator
- *
- * @param integer $creator
- */
- public function setCreator($creator)
- {
- $this->creator = $creator;
- }
- /**
- * Get creator
- *
- * @return integer
- */
- public function getCreator()
- {
- return $this->creator;
- }
- /**
- * Set last_update
- *
- * @param datetime $lastUpdate
- */
- public function setLastUpdate($lastUpdate)
- {
- $this->last_update = $lastUpdate;
- }
- /**
- * Get last_update
- *
- * @return datetime
- */
- public function getLastUpdate()
- {
- return $this->last_update;
- }
- /**
- * Get all available roles
- *
- * @return Array
- */
- public function getRoles()
- {
- return $this->roles;
- }
- /**
- * Returns the salt
- *
- * @return String
- */
- public function getSalt()
- {
- return crypt("vcRockz","salt");
- }
- /**
- * Removes sensitive data from the user
- *
- * @return void
- */
- public function eraseCredentials()
- {
- $this->setPassword('');
- }
- /**
- * Authenticates user
- *
- * @param \Symfony\Component\Security\Core\User\UserInterface $manager
- * @return Boolean
- */
- public function equals(\Symfony\Component\Security\Core\User\UserInterface $manager)
- {
- return $manager->getUsername() === $this->getUsername();
- }
- /**
- * @ORM\preUpdate
- */
- public function setLastUpdateValue()
- {
- $this->last_update = new \DateTime();
- }
- /**
- * @ORM\prePersist
- */
- public function setCreateDateValue()
- {
- $this->create_date = new \DateTime();
- }
- /**
- * Set last_logs
- *
- * @param string $lastLogs
- */
- public function setLastLogs($lastLogs)
- {
- $this->last_logs = $lastLogs;
- }
- /**
- * Get last_logs
- *
- * @return string
- */
- public function getLastLogs()
- {
- return $this->last_logs;
- }
- }
Add Comment
Please, Sign In to add comment