Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.75 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. namespace ShopBundle\Entity;
  5.  
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\AdvancedUserInterface;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10.  
  11.  
  12. /**
  13.  * @ORM\Table(name="user")
  14.  * @ORM\Entity(repositoryClass="ShopBundle\Repository\UserRepository")
  15.  * @UniqueEntity(fields={"email"})
  16.  * @UniqueEntity(fields={"username"})
  17.  * @ORM\HasLifecycleCallbacks
  18.  */
  19. class User implements AdvancedUserInterface, \Serializable
  20. {
  21.  
  22.  
  23.     /**
  24.      * @ORM\Column(type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $id;
  29.  
  30.  
  31.     /**
  32.      * @ORM\Column(type="string", length=20, unique=true)
  33.      *
  34.      * @Assert\NotBlank
  35.      *
  36.      * @Assert\Length(
  37.      *     min=5,
  38.      *     max=20
  39.      *     )
  40.      */
  41.     private $username;
  42.  
  43.     /**
  44.      * @ORM\Column(type="string", length=50, nullable=true)
  45.      * @Assert\NotBlank(groups = {"SetData"} )
  46.      * @Assert\Length(
  47.      *     min=2,
  48.      *     max=20,
  49.      *     groups = {"SetData"}
  50.      * )
  51.      */
  52.  
  53.     private $name = null;
  54.  
  55.     /**
  56.      * @ORM\Column(type="string", length=50, nullable=true)
  57.      * @Assert\NotBlank(groups = {"SetData"})
  58.      * @Assert\Length(
  59.      *     min=2,
  60.      *     max=30,
  61.      *     groups = {"Register"}
  62.      * )
  63.      */
  64.     private $surname = null;
  65.  
  66.     /**
  67.      * @ORM\Column(type="string", length=120, unique=true)
  68.      *
  69.      * @Assert\NotBlank(groups={"Login", "Register"})
  70.      *
  71.      * @Assert\Length(
  72.      *     min=10,
  73.      *     max=100,
  74.      *     groups = {"Login","Register"}
  75.      * )
  76.      */
  77.     private $email;
  78.  
  79.     /**
  80.      * @ORM\Column(type="string", length=64)
  81.      */
  82.     private $password;
  83.  
  84.     /**
  85.      * @Assert\NotBlank(groups = {"Register", "Login"})
  86.      *
  87.      * @Assert\Length(min=6,max=4096,groups = {"Register", "Login"})
  88.      */
  89.     private $plainPassword;
  90.  
  91.     /**
  92.      * @ORM\Column(type="string", nullable=true, length=2)
  93.      *
  94.      * @Assert\NotBlank(groups={"SetData"})
  95.      */
  96.     private $country = null;
  97.  
  98.     /**
  99.      * @ORM\Column(type="string", nullable=true)
  100.      *
  101.      * @Assert\NotBlank(groups={"SetData"})
  102.      *
  103.      */
  104.     private $zipCode = null;
  105.  
  106.     /**
  107.      * @ORM\Column(type="string", nullable=true)
  108.      *
  109.      * @Assert\NotBlank(groups={"SetData"})
  110.      */
  111.     private $street = null;
  112.  
  113.     /**
  114.      * @ORM\Column(type="string", nullable=true)
  115.      *
  116.      * @Assert\NotBlank(groups={"SetData"})
  117.      */
  118.     private $number = null;
  119.  
  120.     /**
  121.      * @ORM\Column(type="string", nullable=true)
  122.      *
  123.      * @Assert\NotBlank(groups={"SetData"})
  124.      */
  125.     private $region = null;
  126.  
  127.     /**
  128.      * @ORM\Column(type="integer", nullable=true)
  129.      *
  130.      * @Assert\NotBlank(groups={"SetData"})
  131.      */
  132.     private $phone = null;
  133.  
  134.     /**
  135.      * @ORM\Column(type="string", nullable=true )
  136.      */
  137.     private $basket = null;
  138.  
  139.     /**
  140.      * @ORM\Column(type="string", nullable=true)
  141.      */
  142.     private $bought = null;
  143.  
  144.     /**
  145.      * @ORM\Column(type="datetime")
  146.      */
  147.     private $joinDate;
  148.  
  149.     /**
  150.      * @ORM\Column(name="account_non_expired", type="boolean")
  151.      */
  152.     private $accountNonExpired = true;
  153.  
  154.     /**
  155.      * @ORM\Column(name="account_non_locked", type="boolean")
  156.      */
  157.     private $accountNonLocked = true;
  158.  
  159.     /**
  160.      * @ORM\Column(name="credentials_non_expired", type="boolean")
  161.      */
  162.     private $credentialsNonExpired = true;
  163.  
  164.     /**
  165.      * @ORM\Column(type="boolean")
  166.      */
  167.     private $enabled = false;
  168.  
  169.     /**
  170.      * @ORM\Column(type="array")
  171.      */
  172.     private $roles;
  173.  
  174.     /**
  175.      * @ORM\Column(name="action_token", type="string", length=20, nullable=true)
  176.      */
  177.     private $actionToken;
  178.  
  179.     public function __construct()
  180.     {
  181.         return $this->joinDate = new \DateTime();
  182.     }
  183.  
  184.     public function isAccountNonExpired(){
  185.         return $this->accountNonExpired;
  186.     }
  187.  
  188.     public function isAccountNonLocked(){
  189.         return $this->accountNonLocked;
  190.     }
  191.  
  192.     public function isCredentialsNonExpired(){
  193.         return $this->credentialsNonExpired;
  194.     }
  195.  
  196.     public function isEnabled(){
  197.         return $this->enabled;
  198.     }
  199.  
  200.     public function getRoles() {
  201.         if(empty($this->roles)){
  202.             return array('ROLE_USER');
  203.         }
  204.         return $this->roles;
  205.     }
  206.  
  207.     public function getPassword(){
  208.         return $this->password;
  209.     }
  210.  
  211.     public function getSalt(){
  212.         return null;
  213.     }
  214.  
  215.     public function getUsername(){
  216.         return $this->username;
  217.     }
  218.  
  219.     public function eraseCredentials(){
  220.         $this->plainPassword = null;
  221.     }
  222.  
  223.  
  224.  
  225.     /**
  226.      * Get id
  227.      *
  228.      * @return integer
  229.      */
  230.     public function getId()
  231.     {
  232.         return $this->id;
  233.     }
  234.  
  235.     /**
  236.      * Set name
  237.      *
  238.      * @param string $name
  239.      *
  240.      * @return User
  241.      */
  242.     public function setName($name)
  243.     {
  244.         $this->name = $name;
  245.  
  246.         return $this;
  247.     }
  248.  
  249.  
  250.     /**
  251.      * Get name
  252.      *
  253.      * @return string
  254.      */
  255.     public function getName()
  256.     {
  257.         return $this->name;
  258.     }
  259.  
  260.     /**
  261.      * Set username
  262.      *
  263.      * @param string $username
  264.      *
  265.      * @return User
  266.      */
  267.     public function setUsername($username)
  268.     {
  269.         $this->username = $username;
  270.  
  271.         return $this;
  272.     }
  273.  
  274.     /**
  275.      * Set surname
  276.      *
  277.      * @param string $surname
  278.      *
  279.      * @return User
  280.      */
  281.     public function setSurname($surname)
  282.     {
  283.         $this->surname = $surname;
  284.  
  285.         return $this;
  286.     }
  287.  
  288.  
  289.     public function getSurname()
  290.     {
  291.         return $this->surname;
  292.     }
  293.  
  294.  
  295.     /**
  296.      * Set email
  297.      *
  298.      * @param string $email
  299.      *
  300.      * @return User
  301.      */
  302.     public function setEmail($email)
  303.     {
  304.         $this->email = $email;
  305.  
  306.         return $this;
  307.     }
  308.  
  309.     /**
  310.      * Get email
  311.      *
  312.      * @return string
  313.      */
  314.     public function getEmail()
  315.     {
  316.         return $this->email;
  317.     }
  318.  
  319.     /**
  320.      * Set password
  321.      *
  322.      * @param string $password
  323.      *
  324.      * @return User
  325.      */
  326.     public function setPassword($password)
  327.     {
  328.         $this->password = $password;
  329.  
  330.         return $this;
  331.     }
  332.  
  333.     /**
  334.      * Set country
  335.      *
  336.      * @param integer $country
  337.      *
  338.      * @return User
  339.      */
  340.     public function setCountry($country)
  341.     {
  342.         $this->country = $country;
  343.  
  344.         return $this;
  345.     }
  346.  
  347.     /**
  348.      * Get country
  349.      *
  350.      * @return integer
  351.      */
  352.     public function getCountry()
  353.     {
  354.         return $this->country;
  355.     }
  356.  
  357.     /**
  358.      * Set zipCode
  359.      *
  360.      * @param string $zipCode
  361.      *
  362.      * @return User
  363.      */
  364.     public function setZipCode($zipCode)
  365.     {
  366.         $this->zipCode = $zipCode;
  367.  
  368.         return $this;
  369.     }
  370.  
  371.     /**
  372.      * Get zipCode
  373.      *
  374.      * @return string
  375.      */
  376.     public function getZipCode()
  377.     {
  378.         return $this->zipCode;
  379.     }
  380.  
  381.     /**
  382.      * Set street
  383.      *
  384.      * @param string $street
  385.      *
  386.      * @return User
  387.      */
  388.     public function setStreet($street)
  389.     {
  390.         $this->street = $street;
  391.  
  392.         return $this;
  393.     }
  394.  
  395.     /**
  396.      * Get street
  397.      *
  398.      * @return string
  399.      */
  400.     public function getStreet()
  401.     {
  402.         return $this->street;
  403.     }
  404.  
  405.     /**
  406.      * Set number
  407.      *
  408.      * @param string $number
  409.      *
  410.      * @return User
  411.      */
  412.     public function setNumber($number)
  413.     {
  414.         $this->number = $number;
  415.  
  416.         return $this;
  417.     }
  418.  
  419.     /**
  420.      * Get number
  421.      *
  422.      * @return string
  423.      */
  424.     public function getNumber()
  425.     {
  426.         return $this->number;
  427.     }
  428.  
  429.     /**
  430.      * Set region
  431.      *
  432.      * @param string $region
  433.      *
  434.      * @return User
  435.      */
  436.     public function setRegion($region)
  437.     {
  438.         $this->region = $region;
  439.  
  440.         return $this;
  441.     }
  442.  
  443.     /**
  444.      * Get region
  445.      *
  446.      * @return string
  447.      */
  448.     public function getRegion()
  449.     {
  450.         return $this->region;
  451.     }
  452.  
  453.     /**
  454.      * Set phone
  455.      *
  456.      * @param integer $phone
  457.      *
  458.      * @return User
  459.      */
  460.     public function setPhone($phone)
  461.     {
  462.         $this->phone = $phone;
  463.  
  464.         return $this;
  465.     }
  466.  
  467.     /**
  468.      * Get phone
  469.      *
  470.      * @return integer
  471.      */
  472.     public function getPhone()
  473.     {
  474.         return $this->phone;
  475.     }
  476.  
  477.     /**
  478.      * Set basket
  479.      *
  480.      * @param string $basket
  481.      *
  482.      * @return User
  483.      */
  484.     public function setBasket($basket)
  485.     {
  486.         $this->basket = $basket;
  487.  
  488.         return $this;
  489.     }
  490.  
  491.     /**
  492.      * Get basket
  493.      *
  494.      * @return string
  495.      */
  496.     public function getBasket()
  497.     {
  498.         return $this->basket;
  499.     }
  500.  
  501.     /**
  502.      * Set bought
  503.      *
  504.      * @param string $bought
  505.      *
  506.      * @return User
  507.      */
  508.     public function setBought($bought)
  509.     {
  510.         $this->bought = $bought;
  511.  
  512.         return $this;
  513.     }
  514.  
  515.     /**
  516.      * Get bought
  517.      *
  518.      * @return string
  519.      */
  520.     public function getBought()
  521.     {
  522.         return $this->bought;
  523.     }
  524.  
  525.     /**
  526.      * Set joinDate
  527.      *
  528.      * @param \DateTime $joinDate
  529.      *
  530.      * @return User
  531.      */
  532.     public function setJoinDate($joinDate)
  533.     {
  534.         $this->joinDate = $joinDate;
  535.  
  536.         return $this;
  537.     }
  538.  
  539.     /**
  540.      * Get joinDate
  541.      *
  542.      * @return \DateTime
  543.      */
  544.     public function getJoinDate()
  545.     {
  546.         return $this->joinDate;
  547.     }
  548.  
  549.     /**
  550.      * Set accountNonExpired
  551.      *
  552.      * @param boolean $accountNonExpired
  553.      *
  554.      * @return User
  555.      */
  556.     public function setAccountNonExpired($accountNonExpired)
  557.     {
  558.         $this->accountNonExpired = $accountNonExpired;
  559.  
  560.         return $this;
  561.     }
  562.  
  563.     /**
  564.      * Get accountNonExpired
  565.      *
  566.      * @return boolean
  567.      */
  568.     public function getAccountNonExpired()
  569.     {
  570.         return $this->accountNonExpired;
  571.     }
  572.  
  573.     /**
  574.      * Set accountNonLocked
  575.      *
  576.      * @param boolean $accountNonLocked
  577.      *
  578.      * @return User
  579.      */
  580.     public function setAccountNonLocked($accountNonLocked)
  581.     {
  582.         $this->accountNonLocked = $accountNonLocked;
  583.  
  584.         return $this;
  585.     }
  586.  
  587.     /**
  588.      * Get accountNonLocked
  589.      *
  590.      * @return boolean
  591.      */
  592.     public function getAccountNonLocked()
  593.     {
  594.         return $this->accountNonLocked;
  595.     }
  596.  
  597.     /**
  598.      * Set credentialsNonExpired
  599.      *
  600.      * @param boolean $credentialsNonExpired
  601.      *
  602.      * @return User
  603.      */
  604.     public function setCredentialsNonExpired($credentialsNonExpired)
  605.     {
  606.         $this->credentialsNonExpired = $credentialsNonExpired;
  607.  
  608.         return $this;
  609.     }
  610.  
  611.     /**
  612.      * Get credentialsNonExpired
  613.      *
  614.      * @return boolean
  615.      */
  616.     public function getCredentialsNonExpired()
  617.     {
  618.         return $this->credentialsNonExpired;
  619.     }
  620.  
  621.     /**
  622.      * Set enabled
  623.      *
  624.      * @param boolean $enabled
  625.      *
  626.      * @return User
  627.      */
  628.     public function setEnabled($enabled)
  629.     {
  630.         $this->enabled = $enabled;
  631.  
  632.         return $this;
  633.     }
  634.  
  635.     /**
  636.      * Get enabled
  637.      *
  638.      * @return boolean
  639.      */
  640.     public function getEnabled()
  641.     {
  642.         return $this->enabled;
  643.     }
  644.  
  645.     /**
  646.      * Set roles
  647.      *
  648.      * @param array $roles
  649.      *
  650.      * @return User
  651.      */
  652.     public function setRoles($roles)
  653.     {
  654.         $this->roles = $roles;
  655.  
  656.         return $this;
  657.     }
  658.  
  659.     /**
  660.      * Set actionToken
  661.      *
  662.      * @param string $actionToken
  663.      *
  664.      * @return User
  665.      */
  666.     public function setActionToken($actionToken)
  667.     {
  668.         $this->actionToken = $actionToken;
  669.  
  670.         return $this;
  671.     }
  672.  
  673.     /**
  674.      * Get actionToken
  675.      *
  676.      * @return string
  677.      */
  678.     public function getActionToken()
  679.     {
  680.         return $this->actionToken;
  681.     }
  682.  
  683.     /**
  684.      * @return mixed
  685.      */
  686.     public function getPlainPassword()
  687.     {
  688.         return $this->plainPassword;
  689.     }
  690.  
  691.     /**
  692.      * @param mixed $plainPassword
  693.      */
  694.     public function setPlainPassword($plainPassword)
  695.     {
  696.         $this->plainPassword = $plainPassword;
  697.     }
  698.  
  699.     public function serialize() {
  700.         return serialize(array(
  701.             $this->id,
  702.             $this->username,
  703.             $this->email,
  704.             $this->name,
  705.             $this->surname,
  706.             $this->password
  707.         ));
  708.     }
  709.  
  710.     public function unserialize($serialized) {
  711.         list(
  712.             $this->id,
  713.             $this->username,
  714.             $this->email,
  715.             $this->name,
  716.             $this->surname,
  717.             $this->password
  718.             ) = unserialize($serialized);
  719.     }
  720.  
  721.  
  722.  
  723. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement