Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.10 KB | None | 0 0
  1. <?php
  2.  
  3. namespace WX\ExchangeBundle\Entity;
  4.  
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\AdvancedUserInterface;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11.  
  12. /**
  13.  * TblUser
  14.  *
  15.  * @ORM\Entity(repositoryClass="WX\ExchangeBundle\Entity\UserRepository")
  16.  *
  17.  * @ORM\Table(name="tbl_user", uniqueConstraints={@ORM\UniqueConstraint(name="email_UNIQUE", columns={"email"}), @ORM\UniqueConstraint(name="fk_profileid_UNIQUE", columns={"fk_profileid"}), @ORM\UniqueConstraint(name="username_UNIQUE", columns={"username"}), @ORM\UniqueConstraint(name="loginid_UNIQUE", columns={"loginid"}), @ORM\UniqueConstraint(name="pwdexpiredtoken_UNIQUE", columns={"pwdexpiredtoken"}), @ORM\UniqueConstraint(name="confirmation_UNIQUE", columns={"confirmation"})}, indexes={@ORM\Index(name="fk_statusid_idx", columns={"fk_status"})})
  18.  * @UniqueEntity(fields={"email"}, groups={"registration"})
  19.  * @UniqueEntity(fields={"username"}, groups={"registration"})
  20.  */
  21. class TblUser implements AdvancedUserInterface, \Serializable
  22. {
  23.     /**
  24.      * @var string
  25.      *
  26.      * @ORM\Column(name="email", type="string", length=254, nullable=false)
  27.      * @Assert\NotBlank(groups={"registration"})
  28.      * @Assert\Email(groups={"registration"})
  29.      */
  30.     protected $email;
  31.  
  32.     /**
  33.      * @var datetime
  34.      *
  35.      * @Gedmo\Timestampable(on="create")
  36.      * @ORM\Column(name="created_at", type="datetime")
  37.      */
  38.      private $createdAt;
  39.      
  40.     /**
  41.      * @var datetime
  42.      *
  43.      * @Gedmo\Timestampable(on="update")
  44.      * @ORM\Column(name="modified_at", type="datetime")
  45.      */
  46.      private $modifiedAt;
  47.  
  48.     /**
  49.      * @var \DateTime
  50.      *
  51.      * @ORM\Column(name="last_login", type="datetime", nullable=true)
  52.      */
  53.     protected $lastLogin;
  54.  
  55.     /**
  56.      * @var string
  57.      *
  58.      * @ORM\Column(name="google_id", type="string", length=254, nullable=true)
  59.      */
  60.     private $googleId;
  61.  
  62.     /**
  63.      * @var string
  64.      *
  65.      * @ORM\Column(name="facebook_id", type="string", length=254, nullable=true)
  66.      */
  67.     private $facebookId;
  68.  
  69.     /**
  70.      * @var string
  71.      *
  72.      * @ORM\Column(name="password", type="blob", length=64, nullable=false)
  73.      * @Assert\NotBlank()
  74.      * @Assert\Length(max = 4096)
  75.      */
  76.     protected $password;
  77.  
  78.     /**
  79.      * @var string
  80.      *
  81.      * @ORM\Column(name="userip", type="string", length=10, nullable=false)
  82.      */
  83.     private $userip;
  84.  
  85.     /**
  86.      * @var integer
  87.      *
  88.      * @ORM\Column(name="fk_status", type="integer", nullable=false)
  89.      */
  90.     private $fkStatus;
  91.  
  92.     /**
  93.      * @var integer
  94.      *
  95.      * @ORM\Column(name="fk_profileid", type="integer", nullable=false)
  96.      */
  97.     private $fkProfileid;
  98.  
  99.     /**
  100.      * @var string
  101.      *
  102.      * @ORM\Column(name="username", type="string", length=25, nullable=true)
  103.      * @Assert\NotBlank(groups={"registration"})
  104.      */
  105.     private $username;
  106.    
  107.     /**
  108.      * @var string
  109.      *
  110.      * @ORM\Column(name="loginid", type="string", length=254, nullable=false)
  111.      */
  112.     private $loginid;
  113.    
  114.     /**
  115.      * @var string
  116.      *
  117.      * @ORM\Column(name="confirmation", type="string", length=64, nullable=true)
  118.      */
  119.     private $confirmation;
  120.    
  121.     /**
  122.      * @var string
  123.      *
  124.      * @ORM\Column(name="pwdexpiredtoken", type="string", length=64, nullable=true)
  125.      */
  126.     private $pwdexpiredtoken;
  127.    
  128.     /**
  129.      * @var integer
  130.      *
  131.      * @ORM\Column(name="pwdexpired", type="integer", nullable=true)
  132.      */
  133.     private $pwdexpired;
  134.  
  135.     /**
  136.      * @var \DateTime
  137.      *
  138.      * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
  139.      */
  140.     private $deletedAt;
  141.  
  142.     /**
  143.      * @var integer
  144.      *
  145.      * @ORM\Column(name="id", type="integer")
  146.      * @ORM\Id
  147.      * @ORM\GeneratedValue(strategy="IDENTITY")
  148.      */
  149.     protected  $id;
  150.    
  151.     /**
  152.      * @ORM\Column(name="is_active", type="boolean")
  153.      */
  154.     private $isActive;
  155.  
  156.    
  157.     /**
  158.      * @ORM\ManyToMany(targetEntity="TblPrivilege", inversedBy="users")
  159.      * @ORM\JoinTable(name="tbl_user_privilege",
  160.             joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
  161.             inverseJoinColumns={@ORM\JoinColumn(name="privilege_id", referencedColumnName="id")})
  162.      */
  163.     private $roles;
  164.    
  165.    
  166.     public function __construct()
  167.     {
  168.         $this->isActive = true;
  169.         $this->roles = new ArrayCollection(array('ROLE_USER'));
  170.     }
  171.    
  172.     public function getRoles()
  173.     {
  174.         return $this->roles->toArray();
  175.     }  
  176.    
  177.     /**
  178.      * @inheritDoc
  179.      */
  180.     public function getSalt()
  181.     {
  182.         // Returns null because we are using bcrypt password encoding
  183.         return null;
  184.     }
  185.  
  186.     /**
  187.      * Set email
  188.      *
  189.      * @param string $email
  190.      * @return TblUser
  191.      */
  192.     public function setEmail($email)
  193.     {
  194.         $this->email = $email;
  195.  
  196.         return $this;
  197.     }
  198.  
  199.     /**
  200.      * Get email
  201.      *
  202.      * @return string
  203.      */
  204.     public function getEmail()
  205.     {
  206.         return $this->email;
  207.     }
  208.  
  209.     /**
  210.      * Get created
  211.      *
  212.      * @return datetime
  213.      */
  214.      public function getCreatedAt()
  215.      {
  216.         return $this->createdAt;
  217.      }
  218.      
  219.     /**
  220.      * Get modified
  221.      *
  222.      * @return datetime
  223.      */
  224.      public function getModifiedAt()
  225.      {
  226.         return $this->modifiedAt;
  227.      }
  228.  
  229.     /**
  230.      * Set lastLogin
  231.      *
  232.      * @param \DateTime $lastLogin
  233.      * @return TblUser
  234.      */
  235.     public function setLastLogin(DateTime $time = NULL)
  236.     {
  237.         $this->lastLogin = $lastLogin;
  238.  
  239.         return $this;
  240.     }
  241.  
  242.     /**
  243.      * Get lastLogin
  244.      *
  245.      * @return \DateTime
  246.      */
  247.     public function getLastLogin()
  248.     {
  249.         return $this->lastLogin;
  250.     }
  251.  
  252.     /**
  253.      * Set googleId
  254.      *
  255.      * @param string $googleId
  256.      * @return TblUser
  257.      */
  258.     public function setGoogleId($googleId)
  259.     {
  260.         $this->googleId = $googleId;
  261.  
  262.         return $this;
  263.     }
  264.  
  265.     /**
  266.      * Get googleId
  267.      *
  268.      * @return string
  269.      */
  270.     public function getGoogleId()
  271.     {
  272.         return $this->googleId;
  273.     }
  274.  
  275.     /**
  276.      * Set facebookId
  277.      *
  278.      * @param string $facebookId
  279.      * @return TblUser
  280.      */
  281.     public function setFacebookId($facebookId)
  282.     {
  283.         $this->facebookId = $facebookId;
  284.  
  285.         return $this;
  286.     }
  287.  
  288.     /**
  289.      * Get facebookId
  290.      *
  291.      * @return string
  292.      */
  293.     public function getFacebookId()
  294.     {
  295.         return $this->facebookId;
  296.     }
  297.  
  298.     /**
  299.      * Set password
  300.      *
  301.      * @param string $password
  302.      * @return TblUser
  303.      */
  304.     public function setPassword($password)
  305.     {
  306.         $this->password = $password;
  307.  
  308.         return $this;
  309.     }
  310.  
  311.     /**
  312.      * Get password
  313.      *
  314.      * @return string
  315.      */
  316.     public function getPassword()
  317.     {
  318.         return $this->password;
  319.     }
  320.  
  321.     /**
  322.      * Set userip
  323.      *
  324.      * @param string $userip
  325.      * @return TblUser
  326.      */
  327.     public function setUserip($userip)
  328.     {
  329.         $this->userip = $userip;
  330.  
  331.         return $this;
  332.     }
  333.  
  334.     /**
  335.      * Get userip
  336.      *
  337.      * @return string
  338.      */
  339.     public function getUserip()
  340.     {
  341.         return $this->userip;
  342.     }
  343.  
  344.     /**
  345.      * Set fkStatus
  346.      *
  347.      * @param integer $fkStatus
  348.      * @return TblUser
  349.      */
  350.     public function setFkStatus($fkStatus)
  351.     {
  352.         $this->fkStatus = $fkStatus;
  353.  
  354.         return $this;
  355.     }
  356.  
  357.     /**
  358.      * Get fkStatus
  359.      *
  360.      * @return integer
  361.      */
  362.     public function getFkStatus()
  363.     {
  364.         return $this->fkStatus;
  365.     }
  366.  
  367.     /**
  368.      * Set fkProfileid
  369.      *
  370.      * @param integer $fkProfileid
  371.      * @return TblUser
  372.      */
  373.     public function setFkProfileid($fkProfileid)
  374.     {
  375.         $this->fkProfileid = $fkProfileid;
  376.  
  377.         return $this;
  378.     }
  379.  
  380.     /**
  381.      * Get fkProfileid
  382.      *
  383.      * @return integer
  384.      */
  385.     public function getFkProfileid()
  386.     {
  387.         return $this->fkProfileid;
  388.     }
  389.  
  390.     /**
  391.      * Set username
  392.      *
  393.      * @param string $username
  394.      * @return TblUser
  395.      */
  396.     public function setUsername($username)
  397.     {
  398.         $this->username = $username;
  399.  
  400.         return $this;
  401.     }
  402.  
  403.     /**
  404.      * Get username
  405.      *
  406.      * @return string
  407.      */
  408.     public function getUsername()
  409.     {
  410.         return $this->username;
  411.     }
  412.  
  413.     /**
  414.      * Set deletedAt
  415.      *
  416.      * @param \DateTime $deletedAt
  417.      * @return TblUser
  418.      */
  419.     public function setDeletedAt($deletedAt)
  420.     {
  421.         $this->deletedAt = $deletedAt;
  422.  
  423.         return $this;
  424.     }
  425.  
  426.     /**
  427.      * Get deletedAt
  428.      *
  429.      * @return \DateTime
  430.      */
  431.     public function getDeletedAt()
  432.     {
  433.         return $this->deletedAt;
  434.     }
  435.  
  436.     /**
  437.      * Get id
  438.      *
  439.      * @return string
  440.      */
  441.     public function getId()
  442.     {
  443.         return $this->id;
  444.     }
  445.    
  446.     /**
  447.      * Get status id as string
  448.      *
  449.      * @return string
  450.      */
  451.      public function __toString() { return (string)$this->id; }
  452.  
  453.     /**
  454.      * @inheritDoc
  455.      */
  456.     public function eraseCredentials()
  457.     {
  458.     }
  459.  
  460.     /**
  461.      * @see \Serializable::serialize()
  462.      */
  463.     public function serialize()
  464.     {
  465.         return serialize(array(
  466.             $this->id,
  467.             $this->username,
  468.             $this->password,
  469.             $this->isActive,
  470.             // see section on salt below
  471.             // $this->salt,
  472.         ));
  473.     }
  474.  
  475.     /**
  476.      * @see \Serializable::unserialize()
  477.      */
  478.     public function unserialize($serialized)
  479.     {
  480.         list (
  481.             $this->id,
  482.             $this->username,
  483.             $this->password,
  484.             $this->isActive,
  485.             // see section on salt below
  486.             // $this->salt
  487.         ) = unserialize($serialized);
  488.     }
  489.    
  490.     public function isAccountNonExpired()
  491.     {
  492.         return true;
  493.     }
  494.  
  495.     public function isAccountNonLocked()
  496.     {
  497.         return true;
  498.     }
  499.  
  500.     public function isCredentialsNonExpired()
  501.     {
  502.         return true;
  503.     }
  504.  
  505.     public function isEnabled()
  506.     {
  507.         return $this->isActive;
  508.     }
  509. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement