src/Entity/User.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Security\Core\User\UserInterface;
  5. use Symfony\Component\Security\Core\User\EquatableInterface;
  6. use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use Symfony\Component\Filesystem\Filesystem;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. //use Symfony\Component\Intl\Intl;
  12. use Symfony\Component\Intl\Countries;
  13. /**
  14.  * User
  15.  *
  16.  * @ORM\Table(name="tam_users")
  17.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  18.  * @ORM\HasLifecycleCallbacks
  19.  */
  20. class User implements UserInterfaceEquatableInterfaceEncoderAwareInterface\Serializable
  21. {
  22.     /**
  23.      * @var int
  24.      *
  25.      * @ORM\Column(name="id", type="integer")
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="IDENTITY")
  28.      */
  29.     private $id;
  30.     
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(name="string_confirm_email", type="string", length=255, nullable=true)
  35.      */
  36.     private $stringConfirmEmail;
  37.     
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(name="string_confirm_recovery", type="string", length=255, nullable=true)
  42.      */
  43.     private $stringConfirmRecovery;
  44.     
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(name="provider", type="string", length=250, nullable=false)
  49.      */
  50.     private $provider;
  51.     
  52.     /**
  53.      * @var string
  54.      *
  55.      * @ORM\Column(name="provider_client_id", type="string", length=255, nullable=true)
  56.      */
  57.     private $providerClientId;
  58.     
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="access_token", type="string", length=250, nullable=true)
  63.      */
  64.     private $accessToken;
  65.     /**
  66.      * @var string
  67.      *
  68.      * @ORM\Column(name="refresh_token", type="string", length=250, nullable=true)
  69.      */
  70.     private $refreshToken;
  71.     /**
  72.      * @var string
  73.      *
  74.      * @ORM\Column(name="token_secret", type="string", length=250, nullable=true)
  75.      */
  76.     private $tokenSecret;
  77.     /**
  78.      * @var string
  79.      *
  80.      * @ORM\Column(name="expires_in", type="string", length=250, nullable=true)
  81.      */
  82.     private $expiresIn;
  83.     
  84.     /**
  85.      * @var string
  86.      *
  87.      * @ORM\Column(name="civility", type="string", length=255, nullable=true)
  88.      */
  89.     private $civility;
  90.     
  91.     /**
  92.      * @var string
  93.      *
  94.      * @ORM\Column(name="nickname", type="string", length=255, nullable=true)
  95.      */
  96.     private $nickname;
  97.     
  98.     /**
  99.      * @var string
  100.      *
  101.      * @ORM\Column(name="lastname", type="string", length=255, nullable=true)
  102.      */
  103.     private $lastname;
  104.     
  105.     /**
  106.      * @var string
  107.      *
  108.      * @ORM\Column(name="firstname", type="string", length=255, nullable=true)
  109.      */
  110.     private $firstname;
  111.     
  112.     /**
  113.      * @var string
  114.      *
  115.      * @ORM\Column(name="email", type="string", length=255, nullable=false)
  116.      */
  117.     private $email;
  118.     
  119.     /**
  120.      * @var string
  121.      *
  122.      * @ORM\Column(name="password", type="string", length=255, nullable=true)
  123.      */
  124.     private $password;
  125.     
  126.     /**
  127.      * @var string
  128.      *
  129.      * @ORM\Column(name="oldpassword", type="string", length=255, nullable=true)
  130.      */
  131.     private $oldPassword;
  132.     
  133.     /**
  134.      * @var string
  135.      *
  136.      * @ORM\Column(name="salt", type="string", length=255, nullable=true)
  137.      */
  138.     private $salt;
  139.     
  140.     /**
  141.      * @var text
  142.      *
  143.      * @ORM\Column(name="roles", type="text", options={"default": "ROLE_USER"})
  144.      */
  145.     private $roles;
  146.     
  147.     /**
  148.      * @var string
  149.      *
  150.      * @ORM\Column(name="address", type="string", length=255, nullable=true)
  151.      */
  152.     private $address;
  153.     
  154.     /**
  155.      * @var string
  156.      *
  157.      * @ORM\Column(name="zipcode", type="string", length=255, nullable=true)
  158.      */
  159.     private $zipcode;
  160.     
  161.     /**
  162.      * @var string
  163.      *
  164.      * @ORM\Column(name="city", type="string", length=255, nullable=true)
  165.      */
  166.     private $city;
  167.     
  168.     /**
  169.      * @var string
  170.      *
  171.      * @ORM\Column(name="country", type="string", length=255, options={"default": "FR"})
  172.      */
  173.     private $country;
  174.     
  175.     /**
  176.      * @var string
  177.      *
  178.      * @ORM\Column(name="lat", type="decimal", precision=14, scale=10, nullable=true)
  179.      */
  180.     private $lat;
  181.     /**
  182.      * @var string
  183.      *
  184.      * @ORM\Column(name="lng", type="decimal", precision=14, scale=10, nullable=true)
  185.      */
  186.     private $lng;
  187.     
  188.     /**
  189.      * @var geography
  190.      *
  191.      * @ORM\Column(name="coordinates", type="geography", nullable=true, options={"geometry_type"="POINT", "srid"=4326})
  192.      */
  193.     private $coordinates;
  194.     
  195.     /**
  196.      * @var boolean
  197.      *
  198.      * @ORM\Column(name="connected", type="boolean", options={"default": FALSE})
  199.      */
  200.     private $connected;
  201.     
  202.     /**
  203.      * @var \DateTime
  204.      *
  205.      * @ORM\Column(name="date_last_connected", type="datetime", nullable=true)
  206.      */
  207.     private $dateLastConnected;
  208.     
  209.     /**
  210.      * @var string
  211.      *
  212.      * @ORM\Column(name="last_connect_mode", type="string", length=255, nullable=true)
  213.      */
  214.     private $lastConnectMode;
  215.     
  216.     /**
  217.      * @var string
  218.      *
  219.      * @ORM\Column(name="smartphone_type", type="string", length=255, nullable=true)
  220.      */
  221.     private $smartphoneType;
  222.     
  223.     /**
  224.      * @var string
  225.      *
  226.      * @ORM\Column(name="smartphone_os_version", type="string", length=255, nullable=true)
  227.      */
  228.     private $smartphoneOsVersion;
  229.     
  230.     /**
  231.      * @var string
  232.      *
  233.      * @ORM\Column(name="smartphone_resolution", type="string", length=255, nullable=true)
  234.      */
  235.     private $smartphoneResolution;
  236.     
  237.     /**
  238.      * @var \App\Entity\AppVersion
  239.      *
  240.      * @ORM\ManyToOne(targetEntity="\App\Entity\AppVersion", fetch="EAGER", inversedBy="users")
  241.      * @ORM\JoinColumns({
  242.      *   @ORM\JoinColumn(name="smartphone_app_version", referencedColumnName="id", onDelete="SET NULL")
  243.      * })
  244.      */
  245.     private $smartphoneAppVersion;
  246.     
  247.     /**
  248.      * @var string
  249.      *
  250.      * @ORM\Column(name="device_tokens", type="text", nullable=true)
  251.      */
  252.     private $deviceTokens;
  253.     
  254.     /**
  255.      * @var \DateTime
  256.      *
  257.      * @ORM\Column(name="date_created", type="datetime", nullable=false)
  258.      */
  259.     private $dateCreated;
  260.     
  261.     /**
  262.      * @var \DateTime
  263.      *
  264.      * @ORM\Column(name="date_updated", type="datetime", nullable=true)
  265.      */
  266.     private $dateUpdated;
  267.     
  268.     /**
  269.      * @var boolean
  270.      *
  271.      * @ORM\Column(name="active", type="boolean", options={"default": FALSE})
  272.      */
  273.     private $active;
  274.     
  275.     /**
  276.      * @var boolean
  277.      *
  278.      * @ORM\Column(name="email_validate", type="boolean", options={"default": FALSE})
  279.      */
  280.     private $emailValidate;
  281.     
  282.     /**
  283.      * @var boolean
  284.      *
  285.      * @ORM\Column(name="deleted", type="boolean", options={"default": FALSE})
  286.      */
  287.     private $deleted;
  288.     
  289.     /**
  290.      * @var \DateTime
  291.      *
  292.      * @ORM\Column(name="date_deleted", type="datetime", nullable=true)
  293.      */
  294.     private $dateDeleted;
  295.     
  296.     /**
  297.      * @var string
  298.      *
  299.      * @ORM\Column(name="vat_number", type="string", length=255, nullable=true)
  300.      */
  301.     private $vatNumber;
  302.     
  303.     /**
  304.      * @var integer
  305.      *
  306.      * @ORM\Column(name="old_id", type="integer", options={"default": 0}, nullable=true)
  307.      */
  308.     private $oldId;
  309.     
  310.     /**
  311.      * @ORM\OneToOne(targetEntity="\App\Entity\Player\Player", mappedBy="user", cascade={"persist", "remove"})
  312.      */
  313.     private $player;
  314.     
  315.     /**
  316.      * @ORM\OneToOne(targetEntity="\App\Entity\Club\Club", mappedBy="user", cascade={"persist", "remove"})
  317.      */
  318.     private $club;
  319.     
  320.     /**
  321.      * @ORM\OneToOne(targetEntity="\App\Entity\Pro\Pro", mappedBy="user", cascade={"persist", "remove"})
  322.      */
  323.     private $pro;
  324.     
  325.     /**
  326.      * @ORM\OneToOne(targetEntity="\App\Entity\League\League", mappedBy="user", cascade={"persist", "remove"})
  327.      */
  328.     private $league;
  329.     
  330.     /**
  331.      * @var ArrayCollection
  332.      *
  333.      * @ORM\OneToMany(targetEntity="\App\Entity\Feed\FeedElement", mappedBy="user", cascade={"persist", "remove"})
  334.      * @ORM\OrderBy({"dateCreated" = "desc"})
  335.      */
  336.     private $feedElements;
  337.     
  338.     /**
  339.      * @var ArrayCollection
  340.      *
  341.      * @ORM\OneToMany(targetEntity="\App\Entity\Feed\FeedMessage", mappedBy="sender", cascade={"persist", "remove"})
  342.      */
  343.     private $feedMessages;
  344.     
  345.     /**
  346.      * @var ArrayCollection
  347.      *
  348.      * @ORM\OneToMany(targetEntity="\App\Entity\Message\Message", mappedBy="sender", cascade={"persist", "remove"})
  349.      */
  350.     private $sendedMessages;
  351.     
  352.     /**
  353.      * @var ArrayCollection
  354.      *
  355.      * @ORM\OneToMany(targetEntity="\App\Entity\Message\Message", mappedBy="recipient", cascade={"persist", "remove"})
  356.      */
  357.     private $receivedMessages;
  358.     
  359.     /**
  360.      * @var ArrayCollection
  361.      *
  362.      * @ORM\OneToMany(targetEntity="\App\Entity\Log\LogUser", mappedBy="user", cascade={"persist", "remove"})
  363.      */
  364.     private $connectionLogs;
  365.     
  366.     /**
  367.      * @var ArrayCollection
  368.      *
  369.      * @ORM\OneToMany(targetEntity="App\Entity\Friend", mappedBy="user", cascade={"persist", "remove"})
  370.      */
  371.     private $friends;
  372.     
  373.     /**
  374.      * @var ArrayCollection
  375.      *
  376.      * @ORM\OneToMany(targetEntity="\App\Entity\Friend", mappedBy="friend", cascade={"persist", "remove"}, orphanRemoval=true)
  377.      */
  378.     private $friendRequests;
  379.     
  380.     /**
  381.      * @var ArrayCollection
  382.      *
  383.      * @ORM\OneToMany(targetEntity="App\Entity\UserFollow", mappedBy="user", cascade={"persist", "remove"})
  384.      */
  385.     private $followUsers;
  386.     
  387.     /**
  388.      * @var ArrayCollection
  389.      *
  390.      * @ORM\OneToMany(targetEntity="App\Entity\UserFollow", mappedBy="userFollowed", cascade={"persist", "remove"})
  391.      */
  392.     private $followers;
  393.     
  394.     /**
  395.      * @var string
  396.      *
  397.      * @ORM\Column(name="avatar", type="string", length=255, nullable=true)
  398.      */
  399.     private $avatar;
  400.     
  401.     /**
  402.      * @var string
  403.      *
  404.      * @ORM\Column(name="url_avatar_provider", type="text", nullable=true)
  405.      */
  406.     private $urlAvatarForProvider;
  407.     
  408.     
  409.      /**
  410.      * Image avatarFile
  411.      *
  412.      * @var File
  413.      *
  414.      * @Assert\File(
  415.      *     maxSize = "5M",
  416.      *     mimeTypes = {"image/jpeg", "image/gif", "image/png", "image/tiff"},
  417.      *     maxSizeMessage = "The maxmimum allowed file size is 5MB.",
  418.      *     mimeTypesMessage = "Only the filetypes image are allowed."
  419.      * )
  420.      */
  421.     protected $avatarFile;
  422.     
  423.     /**
  424.      * @var float
  425.      *
  426.      */
  427.     private $distance;
  428.     
  429.     
  430.     public function __construct()
  431.     {
  432.         $this->active true;
  433.         $this->emailValidate false;
  434.         $this->deleted false;
  435.         $this->dateCreated = new \DateTime();
  436.         $this->dateUpdated = new \DateTime();
  437.         $this->roles 'ROLE_USER';
  438.         $this->avatarFile null;
  439.         $this->connected false;
  440.         $this->feedElements = new ArrayCollection();
  441.         $this->feedMessages = new ArrayCollection();
  442.         $this->distance 0;
  443.         
  444.         $this->friends = new ArrayCollection();
  445.         $this->friendRequests = new ArrayCollection();
  446.         
  447.         $this->followUsers = new ArrayCollection();
  448.         $this->followers = new ArrayCollection();
  449.     }
  450.     /**
  451.      * Get id
  452.      *
  453.      * @return int
  454.      */
  455.     public function getId()
  456.     {
  457.         return $this->id;
  458.     }
  459.     
  460.     /**
  461.      * Set stringConfirmEmail
  462.      *
  463.      * @param string $stringConfirmEmail
  464.      *
  465.      * @return User
  466.      */
  467.     public function setStringConfirmEmail($stringConfirmEmail)
  468.     {
  469.         $this->stringConfirmEmail $stringConfirmEmail;
  470.         return $this;
  471.     }
  472.     /**
  473.      * Get stringConfirmEmail
  474.      *
  475.      * @return string
  476.      */
  477.     public function getStringConfirmEmail()
  478.     {
  479.         return $this->stringConfirmEmail;
  480.     }
  481.     
  482.     /**
  483.      * Set stringConfirmRecovery
  484.      *
  485.      * @param string $stringConfirmRecovery
  486.      *
  487.      * @return User
  488.      */
  489.     public function setStringConfirmRecovery($stringConfirmRecovery)
  490.     {
  491.         $this->stringConfirmRecovery $stringConfirmRecovery;
  492.         return $this;
  493.     }
  494.     /**
  495.      * Get stringConfirmRecovery
  496.      *
  497.      * @return string
  498.      */
  499.     public function getStringConfirmRecovery()
  500.     {
  501.         return $this->stringConfirmRecovery;
  502.     }
  503.     
  504.     /**
  505.      * Set provider
  506.      *
  507.      * @param string $provider
  508.      *
  509.      * @return User
  510.      */
  511.     public function setProvider($provider)
  512.     {
  513.         $this->provider $provider;
  514.         return $this;
  515.     }
  516.     /**
  517.      * Get provider
  518.      *
  519.      * @return string
  520.      */
  521.     public function getProvider()
  522.     {
  523.         return $this->provider;
  524.     }
  525.     
  526.     /**
  527.      * Set providerClientId
  528.      *
  529.      * @param string $providerClientId
  530.      *
  531.      * @return User
  532.      */
  533.     public function setProviderClientId($providerClientId)
  534.     {
  535.         $this->providerClientId $providerClientId;
  536.         return $this;
  537.     }
  538.     /**
  539.      * Get providerClientId
  540.      *
  541.      * @return string
  542.      */
  543.     public function getProviderClientId()
  544.     {
  545.         return $this->providerClientId;
  546.     }
  547.     
  548.     /**
  549.      * Set accessToken
  550.      *
  551.      * @param string $accessToken
  552.      *
  553.      * @return User
  554.      */
  555.     public function setAccessToken($accessToken)
  556.     {
  557.         $this->accessToken $accessToken;
  558.         return $this;
  559.     }
  560.     /**
  561.      * Get accessToken
  562.      *
  563.      * @return string
  564.      */
  565.     public function getAccessToken()
  566.     {
  567.         return $this->accessToken;
  568.     }
  569.     
  570.     /**
  571.      * Set refreshToken
  572.      *
  573.      * @param string $refreshToken
  574.      *
  575.      * @return User
  576.      */
  577.     public function setRefreshToken($refreshToken)
  578.     {
  579.         $this->refreshToken $refreshToken;
  580.         return $this;
  581.     }
  582.     /**
  583.      * Get refreshToken
  584.      *
  585.      * @return string
  586.      */
  587.     public function getRefreshToken()
  588.     {
  589.         return $this->refreshToken;
  590.     }
  591.     
  592.     /**
  593.      * Set tokenSecret
  594.      *
  595.      * @param string $tokenSecret
  596.      *
  597.      * @return User
  598.      */
  599.     public function setTokenSecret($tokenSecret)
  600.     {
  601.         $this->tokenSecret $tokenSecret;
  602.         return $this;
  603.     }
  604.     /**
  605.      * Get tokenSecret
  606.      *
  607.      * @return string
  608.      */
  609.     public function getTokenSecret()
  610.     {
  611.         return $this->tokenSecret;
  612.     }
  613.     
  614.     /**
  615.      * Set expiresIn
  616.      *
  617.      * @param string $expiresIn
  618.      *
  619.      * @return User
  620.      */
  621.     public function setExpiresIn($expiresIn)
  622.     {
  623.         $this->expiresIn $expiresIn;
  624.         return $this;
  625.     }
  626.     /**
  627.      * Get expiresIn
  628.      *
  629.      * @return string
  630.      */
  631.     public function getExpiresIn()
  632.     {
  633.         return $this->expiresIn;
  634.     }
  635.     
  636.     
  637.     /**
  638.      * Set civility
  639.      *
  640.      * @param string $civility
  641.      *
  642.      * @return User
  643.      */
  644.     public function setCivility($civility)
  645.     {
  646.         $this->civility $civility;
  647.         return $this;
  648.     }
  649.     /**
  650.      * Get civility
  651.      *
  652.      * @return string
  653.      */
  654.     public function getCivility()
  655.     {
  656.         return $this->civility;
  657.     }
  658.     
  659.     /**
  660.      * Set nickname
  661.      *
  662.      * @param string $nickname
  663.      *
  664.      * @return User
  665.      */
  666.     public function setNickname($nickname)
  667.     {
  668.         $this->nickname $nickname;
  669.         return $this;
  670.     }
  671.     /**
  672.      * Get nickname
  673.      *
  674.      * @return string
  675.      */
  676.     public function getNickname()
  677.     {
  678.         if($this->getPlayer() && $this->nickname == ""){
  679.             //return strtoupper($this->getLastname())." ".substr($this->firstname, 0, 1).".";
  680.             if($this->getLastname() != ""){
  681.                 return strtoupper($this->getLastname());
  682.             }else{
  683.                 return "Tam nickname undefined";
  684.             }
  685.         }
  686.             
  687.         return $this->nickname;
  688.     }
  689.     
  690.     /**
  691.      * Set lastname
  692.      *
  693.      * @param string $lastname
  694.      *
  695.      * @return User
  696.      */
  697.     public function setLastname($lastname)
  698.     {
  699.         $this->lastname $lastname;
  700.         return $this;
  701.     }
  702.     /**
  703.      * Get lastname
  704.      *
  705.      * @return string
  706.      */
  707.     public function getLastname()
  708.     {
  709.         return $this->lastname;
  710.     }
  711.     
  712.     /**
  713.      * Set firstname
  714.      *
  715.      * @param string $firstname
  716.      *
  717.      * @return Administrator
  718.      */
  719.     public function setFirstname($firstname)
  720.     {
  721.         $this->firstname $firstname;
  722.         return $this;
  723.     }
  724.     /**
  725.      * Get firstname
  726.      *
  727.      * @return string
  728.      */
  729.     public function getFirstname()
  730.     {
  731.         return $this->firstname;
  732.     }
  733.     
  734.     /**
  735.      * Set email
  736.      *
  737.      * @param string $email
  738.      *
  739.      * @return User
  740.      */
  741.     public function setEmail($email)
  742.     {
  743.         $this->email strtolower($email);
  744.         return $this;
  745.     }
  746.     /**
  747.      * Get email
  748.      *
  749.      * @return string
  750.      */
  751.     public function getEmail()
  752.     {
  753.         return $this->email;
  754.     }
  755.     
  756.     /**
  757.      * Set password
  758.      *
  759.      * @param string $password
  760.      *
  761.      * @return User
  762.      */
  763.     public function setPassword($password)
  764.     {
  765.         $this->password $password;
  766.         return $this;
  767.     }
  768.     /**
  769.      * Get password
  770.      *
  771.      * @return string
  772.      */
  773.     public function getPassword()
  774.     {
  775.         //return $this->password;
  776.         return null === $this->password $this->oldPassword $this->password;
  777.     }
  778.     
  779.     /**
  780.      * Set oldPassword
  781.      *
  782.      * @param string $password
  783.      *
  784.      * @return User
  785.      */
  786.     public function setOldPassword($oldPassword)
  787.     {
  788.         $this->oldPassword $oldPassword;
  789.         return $this;
  790.     }
  791.     /**
  792.      * Get oldPassword
  793.      *
  794.      * @return string
  795.      */
  796.     public function getOldPassword()
  797.     {
  798.         return $this->oldPassword;
  799.     }
  800.     
  801.     /**
  802.      * Set roles
  803.      *
  804.      * @param string $roles
  805.      *
  806.      * @return User
  807.      */
  808.     public function setRoles($roles)
  809.     {
  810.         $this->roles $roles;
  811.         return $this;
  812.     }
  813.     
  814.     
  815.      /**
  816.      * Get roles
  817.      *
  818.      * @return string
  819.      */
  820.     public function getRoles()
  821.     {
  822.         return array($this->roles);
  823.     }
  824.     
  825.     
  826.     
  827.     /**
  828.      * Set salt
  829.      *
  830.      * @param string $salt
  831.      *
  832.      * @return User
  833.      */
  834.     public function setSalt($salt)
  835.     {
  836.         $this->salt $salt;
  837.         return $this;
  838.     }
  839.     
  840.     
  841.     /**
  842.      * Get salt
  843.      *
  844.      * @return string
  845.      */
  846.     public function getSalt()
  847.     {
  848.         // you *may* need a real salt depending on your encoder
  849.         // see section on salt below
  850.         //return null;
  851.         //return "TEST";
  852.         return $this->salt;
  853.     }
  854.     
  855.     
  856.     /**
  857.      * Set address
  858.      *
  859.      * @param string $address
  860.      *
  861.      * @return User
  862.      */
  863.     public function setAddress($address)
  864.     {
  865.         $this->address $address;
  866.         return $this;
  867.     }
  868.     /**
  869.      * Get address
  870.      *
  871.      * @return string
  872.      */
  873.     public function getAddress()
  874.     {
  875.         return $this->address;
  876.     }
  877.     
  878.     /**
  879.      * Set zipcode
  880.      *
  881.      * @param string $zipcode
  882.      *
  883.      * @return User
  884.      */
  885.     public function setZipcode($zipcode)
  886.     {
  887.         $this->zipcode $zipcode;
  888.         return $this;
  889.     }
  890.     /**
  891.      * Get zipcode
  892.      *
  893.      * @return string
  894.      */
  895.     public function getZipcode()
  896.     {
  897.         return $this->zipcode;
  898.     }
  899.     
  900.     /**
  901.      * Set city
  902.      *
  903.      * @param string $city
  904.      *
  905.      * @return User
  906.      */
  907.     public function setCity($city)
  908.     {
  909.         $this->city $city;
  910.         return $this;
  911.     }
  912.     /**
  913.      * Get city
  914.      *
  915.      * @return string
  916.      */
  917.     public function getCity()
  918.     {
  919.         return $this->city;
  920.     }
  921.     
  922.     /**
  923.      * Set country
  924.      *
  925.      * @param string $country
  926.      *
  927.      * @return User
  928.      */
  929.     public function setCountry($country)
  930.     {
  931.         $this->country $country;
  932.         return $this;
  933.     }
  934.     /**
  935.      * Get country
  936.      *
  937.      * @return string
  938.      */
  939.     public function getCountry()
  940.     {
  941.         return $this->country;
  942.     }
  943.     
  944.     /**
  945.      * Set lat
  946.      *
  947.      * @param string $lat
  948.      * @return User
  949.      */
  950.     public function setLat($lat)
  951.     {
  952.         $this->lat $lat;
  953.         return $this;
  954.     }
  955.     /**
  956.      * Get lat
  957.      *
  958.      * @return string 
  959.      */
  960.     public function getLat()
  961.     {
  962.         return $this->lat;
  963.     }
  964.     /**
  965.      * Set lng
  966.      *
  967.      * @param string $lng
  968.      * @return User
  969.      */
  970.     public function setLng($lng)
  971.     {
  972.         $this->lng $lng;
  973.         return $this;
  974.     }
  975.     /**
  976.      * Get lng
  977.      *
  978.      * @return string 
  979.      */
  980.     public function getLng()
  981.     {
  982.         return $this->lng;
  983.     }
  984.     
  985.     /**
  986.      * Set coordinates
  987.      *
  988.      * @param string $coordinates
  989.      * @return User
  990.      */
  991.     public function setCoordinates($coordinates)
  992.     {
  993.         $this->coordinates $coordinates;  
  994.         return $this;
  995.     }
  996.     /**
  997.      * Get coordinates
  998.      *
  999.      * @return \geography 
  1000.      */
  1001.     public function getCoordinates()
  1002.     {
  1003.         return $this->coordinates;
  1004.     }
  1005.     
  1006.     /**
  1007.      * Set connected
  1008.      *
  1009.      * @param boolean $connected
  1010.      *
  1011.      * @return User
  1012.      */
  1013.     public function setConnected($connected)
  1014.     {
  1015.         $this->connected $connected;
  1016.         return $this;
  1017.     }
  1018.     /**
  1019.      * Get connected
  1020.      *
  1021.      * @return boolean
  1022.      */
  1023.     public function getConnected()
  1024.     {
  1025.         return $this->connected;
  1026.     }
  1027.     
  1028.     /**
  1029.      * Set dateLastConnected
  1030.      *
  1031.      * @param \DateTime $dateLastConnected
  1032.      *
  1033.      * @return User
  1034.      */
  1035.     public function setDateLastConnected($dateLastConnected)
  1036.     {
  1037.         $this->dateLastConnected $dateLastConnected;
  1038.         return $this;
  1039.     }
  1040.     /**
  1041.      * Get dateLastConnected
  1042.      *
  1043.      * @return \DateTime
  1044.      */
  1045.     public function getDateLastConnected()
  1046.     {
  1047.         return $this->dateLastConnected;
  1048.     }
  1049.     
  1050.     /**
  1051.      * Set lastConnectMode
  1052.      *
  1053.      * @param string $lastConnectMode
  1054.      *
  1055.      * @return User
  1056.      */
  1057.     public function setLastConnectMode($lastConnectMode)
  1058.     {
  1059.         $this->lastConnectMode $lastConnectMode;
  1060.         return $this;
  1061.     }
  1062.     /**
  1063.      * Get lastConnectMode
  1064.      *
  1065.      * @return string
  1066.      */
  1067.     public function getLastConnectMode()
  1068.     {
  1069.         return $this->lastConnectMode;
  1070.     }
  1071.     
  1072.     /**
  1073.      * Set smartphoneType
  1074.      *
  1075.      * @param string $smartphoneType
  1076.      *
  1077.      * @return User
  1078.      */
  1079.     public function setSmartphoneType($smartphoneType)
  1080.     {
  1081.         $this->smartphoneType $smartphoneType;
  1082.         return $this;
  1083.     }
  1084.     /**
  1085.      * Get smartphoneType
  1086.      *
  1087.      * @return string
  1088.      */
  1089.     public function getSmartphoneType()
  1090.     {
  1091.         return $this->smartphoneType;
  1092.     }
  1093.     
  1094.     /**
  1095.      * Set smartphoneOsVersion
  1096.      *
  1097.      * @param string $smartphoneOsVersion
  1098.      *
  1099.      * @return User
  1100.      */
  1101.     public function setSmartphoneOsVersion($smartphoneOsVersion)
  1102.     {
  1103.         $this->smartphoneOsVersion $smartphoneOsVersion;
  1104.         return $this;
  1105.     }
  1106.     /**
  1107.      * Get smartphoneOsVersion
  1108.      *
  1109.      * @return string
  1110.      */
  1111.     public function getSmartphoneOsVersion()
  1112.     {
  1113.         return $this->smartphoneOsVersion;
  1114.     }
  1115.     
  1116.     /**
  1117.      * Set smartphoneResolution
  1118.      *
  1119.      * @param string $smartphoneResolution
  1120.      *
  1121.      * @return User
  1122.      */
  1123.     public function setSmartphoneResolution($smartphoneResolution)
  1124.     {
  1125.         $this->smartphoneResolution $smartphoneResolution;
  1126.         return $this;
  1127.     }
  1128.     /**
  1129.      * Get smartphoneResolution
  1130.      *
  1131.      * @return string
  1132.      */
  1133.     public function getSmartphoneResolution()
  1134.     {
  1135.         return $this->smartphoneResolution;
  1136.     }
  1137.     
  1138.     /**
  1139.      * Set smartphoneAppVersion
  1140.      *
  1141.      * @param RankingSystem $smartphoneAppVersion
  1142.      *
  1143.      * @return user
  1144.      */
  1145.     public function setSmartphoneAppVersion($smartphoneAppVersion)
  1146.     {
  1147.         $this->smartphoneAppVersion $smartphoneAppVersion;
  1148.         return $this;
  1149.     }
  1150.     /**
  1151.      * Get smartphoneAppVersion
  1152.      *
  1153.      * @return AppVersion
  1154.      */
  1155.     public function getSmartphoneAppVersion()
  1156.     {
  1157.         return $this->smartphoneAppVersion;
  1158.     }
  1159.     
  1160.     /**
  1161.      * Set deviceTokens
  1162.      *
  1163.      * @param string $deviceTokens
  1164.      *
  1165.      * @return User
  1166.      */
  1167.     public function setDeviceTokens($deviceTokens)
  1168.     {
  1169.         $this->deviceTokens $deviceTokens;
  1170.         return $this;
  1171.     }
  1172.     /**
  1173.      * Get deviceTokens
  1174.      *
  1175.      * @return string
  1176.      */
  1177.     public function getDeviceTokens()
  1178.     {
  1179.         return $this->deviceTokens;
  1180.     }
  1181.     
  1182.     /**
  1183.      * Set dateCreated
  1184.      *
  1185.      * @param \DateTime $dateCreated
  1186.      *
  1187.      * @return User
  1188.      */
  1189.     public function setDateCreated($dateCreated)
  1190.     {
  1191.         $this->dateCreated $dateCreated;
  1192.         return $this;
  1193.     }
  1194.     /**
  1195.      * Get dateCreated
  1196.      *
  1197.      * @return \DateTime
  1198.      */
  1199.     public function getDateCreated()
  1200.     {
  1201.         return $this->dateCreated;
  1202.     }
  1203.     
  1204.     /**
  1205.      * Set dateUpdated
  1206.      *
  1207.      * @param \DateTime $dateUpdated
  1208.      *
  1209.      * @return User
  1210.      */
  1211.     public function setDateUpdated($dateUpdated)
  1212.     {
  1213.         $this->dateUpdated $dateUpdated;
  1214.         return $this;
  1215.     }
  1216.     /**
  1217.      * Get dateUpdated
  1218.      *
  1219.      * @return \DateTime
  1220.      */
  1221.     public function getDateUpdated()
  1222.     {
  1223.         return $this->dateUpdated;
  1224.     }
  1225.     
  1226.      /**
  1227.      * Set active
  1228.      *
  1229.      * @param boolean $active
  1230.      *
  1231.      * @return User
  1232.      */
  1233.     public function setActive($active)
  1234.     {
  1235.         $this->active $active;
  1236.         return $this;
  1237.     }
  1238.     /**
  1239.      * Get active
  1240.      *
  1241.      * @return boolean
  1242.      */
  1243.     public function getActive()
  1244.     {
  1245.         return $this->active;
  1246.     }
  1247.     
  1248.     /**
  1249.      * Set emailValidate
  1250.      *
  1251.      * @param boolean $emailValidate
  1252.      *
  1253.      * @return User
  1254.      */
  1255.     public function setEmailValidate($emailValidate)
  1256.     {
  1257.         $this->emailValidate $emailValidate;
  1258.         return $this;
  1259.     }
  1260.     /**
  1261.      * Get emailValidate
  1262.      *
  1263.      * @return boolean
  1264.      */
  1265.     public function getEmailValidate()
  1266.     {
  1267.         return $this->emailValidate;
  1268.     }
  1269.     
  1270.     /**
  1271.      * Set dateActive
  1272.      *
  1273.      * @param \DateTime $dateActive
  1274.      *
  1275.      * @return User
  1276.      */
  1277.     public function setDateActive($dateActive)
  1278.     {
  1279.         $this->dateActive $dateActive;
  1280.         return $this;
  1281.     }
  1282.     /**
  1283.      * Get dateActive
  1284.      *
  1285.      * @return \DateTime
  1286.      */
  1287.     public function getDateActive()
  1288.     {
  1289.         return $this->dateActive;
  1290.     }
  1291.     
  1292.     /**
  1293.      * Set deleted
  1294.      *
  1295.      * @param boolean $deleted
  1296.      *
  1297.      * @return User
  1298.      */
  1299.     public function setDeleted($deleted)
  1300.     {
  1301.         $this->deleted $deleted;
  1302.         return $this;
  1303.     }
  1304.     /**
  1305.      * Get deleted
  1306.      *
  1307.      * @return boolean
  1308.      */
  1309.     public function getDeleted()
  1310.     {
  1311.         return $this->deleted;
  1312.     }
  1313.     
  1314.     
  1315.     /**
  1316.      * Set dateDeleted
  1317.      *
  1318.      * @param \DateTime $dateDeleted
  1319.      *
  1320.      * @return User
  1321.      */
  1322.     public function setDateDeleted($datedeleted)
  1323.     {
  1324.         $this->dateDeleted $datedeleted;
  1325.         return $this;
  1326.     }
  1327.     /**
  1328.      * Get dateDeleted
  1329.      *
  1330.      * @return \DateTime
  1331.      */
  1332.     public function getDateDeleted()
  1333.     {
  1334.         return $this->dateDeleted;
  1335.     }
  1336.     
  1337.     /**
  1338.      * Set vatNumber
  1339.      *
  1340.      * @param string $vatNumber
  1341.      *
  1342.      * @return User
  1343.      */
  1344.     public function setVatNumber($vatNumber)
  1345.     {
  1346.         $this->vatNumber $vatNumber;
  1347.         return $this;
  1348.     }
  1349.     /**
  1350.      * Get vatNumber
  1351.      *
  1352.      * @return string
  1353.      */
  1354.     public function getVatNumber()
  1355.     {       
  1356.         return $this->vatNumber;
  1357.     }
  1358.     
  1359.     /**
  1360.      * Set oldId
  1361.      *
  1362.      * @param integer $oldId
  1363.      *
  1364.      * @return User
  1365.      */
  1366.     public function setOldId($oldId)
  1367.     {
  1368.         $this->oldId $oldId;
  1369.         return $this;
  1370.     }
  1371.     /**
  1372.      * Get oldId
  1373.      *
  1374.      * @return integer
  1375.      */
  1376.     public function getOldId()
  1377.     {
  1378.         return $this->oldId;
  1379.     }
  1380.     
  1381.     /**
  1382.      * Set Player
  1383.      *
  1384.      * @param \App\Entity\Player\Player $player
  1385.      *
  1386.      * @return User
  1387.      */
  1388.     public function setPlayer(\App\Entity\Player\Player $player)
  1389.     {
  1390.         //$player->setUser($this);
  1391.         $this->player $player;
  1392.         return $this;
  1393.     }
  1394.     /**
  1395.      * Get player
  1396.      *
  1397.      * @return \App\Entity\Player\Player
  1398.      */
  1399.     public function getPlayer()
  1400.     {
  1401.         return $this->player;
  1402.     }
  1403.     
  1404.     /**
  1405.      * Set Club
  1406.      *
  1407.      * @param \App\Entity\Club\Club $club
  1408.      *
  1409.      * @return User
  1410.      */
  1411.     public function setClub(\App\Entity\Club\Club $club)
  1412.     {
  1413.         $this->club $club;
  1414.         return $this;
  1415.     }
  1416.     /**
  1417.      * Get club
  1418.      *
  1419.      * @return \App\Entity\Club\Club
  1420.      */
  1421.     public function getClub()
  1422.     {
  1423.         return $this->club;
  1424.     }
  1425.     
  1426.     /**
  1427.      * Set Pro
  1428.      *
  1429.      * @param \App\Entity\Pro\Pro $pro
  1430.      *
  1431.      * @return User
  1432.      */
  1433.     public function setPro(\App\Entity\Pro\Pro $pro)
  1434.     {
  1435.         $this->pro $pro;
  1436.         return $this;
  1437.     }
  1438.     /**
  1439.      * Get pro
  1440.      *
  1441.      * @return \App\Entity\Pro\Pro
  1442.      */
  1443.     public function getPro()
  1444.     {
  1445.         return $this->pro;
  1446.     }
  1447.     
  1448.     /**
  1449.      * Set league
  1450.      *
  1451.      * @param \App\Entity\League\League $league
  1452.      *
  1453.      * @return User
  1454.      */
  1455.     public function setLeague(\App\Entity\League\League $league)
  1456.     {
  1457.         $this->league $league;
  1458.         return $this;
  1459.     }
  1460.     /**
  1461.      * Get league
  1462.      *
  1463.      * @return \App\Entity\League\League
  1464.      */
  1465.     public function getLeague()
  1466.     {
  1467.         return $this->league;
  1468.     }
  1469.     
  1470.     /**
  1471.      * Add feedElement
  1472.      *
  1473.      * @param \App\Entity\Feed\FeedElement $feedElement
  1474.      *
  1475.      * @return User
  1476.      */
  1477.     public function addFeedElement(\App\Entity\Feed\FeedElement $feedElement)
  1478.     {
  1479.         $this->feedElements[] = $feedElement;
  1480.         return $this;
  1481.     }
  1482.     /**
  1483.      * Remove feedElement
  1484.      *
  1485.      * @param \App\Entity\Feed\FeedElement $feedElement
  1486.      */
  1487.     public function removeFeedElement(\App\Entity\Feed\FeedElement $feedElement)
  1488.     {
  1489.         $this->feedElements->removeElement($feedElement);
  1490.     }
  1491.     /**
  1492.      * Get feedElements
  1493.      *
  1494.      * @return \Doctrine\Common\Collections\Collection
  1495.      */
  1496.     public function getFeedElements()
  1497.     {
  1498.         return $this->feedElements;
  1499.     }
  1500.     
  1501.     /**
  1502.      * Add feedMessage
  1503.      *
  1504.      * @param \App\Entity\Feed\FeedMessage $feedMesage
  1505.      *
  1506.      * @return User
  1507.      */
  1508.     public function addFeedMessage(\App\Entity\Feed\FeedMessage $feedMessage)
  1509.     {
  1510.         $this->feedMessages[] = $feedMessage;
  1511.         return $this;
  1512.     }
  1513.     /**
  1514.      * Remove feedMessage
  1515.      *
  1516.      * @param \App\Entity\Feed\FeedMessage $feedMessage
  1517.      */
  1518.     public function removeFeedMessage(\App\Entity\Feed\FeedMessage $feedMessage)
  1519.     {
  1520.         $this->feedMessages->removeElement($feedMessage);
  1521.     }
  1522.     /**
  1523.      * Get feedMessages
  1524.      *
  1525.      * @return \Doctrine\Common\Collections\Collection
  1526.      */
  1527.     public function getFeedMessages()
  1528.     {
  1529.         return $this->feedMessages;
  1530.     }
  1531.     
  1532.     /**
  1533.      * Add message
  1534.      *
  1535.      * @param \App\Entity\Message\Message $message
  1536.      *
  1537.      * @return User
  1538.      */
  1539.     public function addSendedMessage(\App\Entity\Message\Message $message)
  1540.     {
  1541.         $this->sendedMessages[] = $message;
  1542.         return $this;
  1543.     }
  1544.     /**
  1545.      * Remove message
  1546.      *
  1547.      * @param \App\Entity\Message\Message $message
  1548.      */
  1549.     public function removeSendedMessage(\App\Entity\Message\Message $message)
  1550.     {
  1551.         $this->sendedMessages->removeElement($message);
  1552.     }
  1553.     /**
  1554.      * Get sendedMessages
  1555.      *
  1556.      * @return \Doctrine\Common\Collections\Collection
  1557.      */
  1558.     public function getSendedMessages()
  1559.     {
  1560.         return $this->sendedMessages;
  1561.     }
  1562.     
  1563.     /**
  1564.      * Add receivedMessage
  1565.      *
  1566.      * @param \App\Entity\Message\Message $message
  1567.      *
  1568.      * @return User
  1569.      */
  1570.     public function addReceivedMessage(\App\Entity\Message\Message $message)
  1571.     {
  1572.         $this->receivedMessages[] = $message;
  1573.         return $this;
  1574.     }
  1575.     /**
  1576.      * Remove receivedMessage
  1577.      *
  1578.      * @param \App\Entity\Message\Message $message
  1579.      */
  1580.     public function removeReceivedMessage(\App\Entity\Message\Message $message)
  1581.     {
  1582.         $this->receivedMessages->removeElement($message);
  1583.     }
  1584.     /**
  1585.      * Get receivedMessages
  1586.      *
  1587.      * @return \Doctrine\Common\Collections\Collection
  1588.      */
  1589.     public function getReceivedMessages()
  1590.     {
  1591.         return $this->receivedMessages;
  1592.     }
  1593.     
  1594.     /**
  1595.      * Add connectionLog
  1596.      *
  1597.      * @param \App\Entity\Log\LogUser $connectionLog
  1598.      *
  1599.      * @return User
  1600.      */
  1601.     public function addConnectionLog(\App\Entity\Log\LogUser $connectionLog)
  1602.     {
  1603.         $this->connectionLogs[] = $connectionLog;
  1604.         return $this;
  1605.     }
  1606.     /**
  1607.      * Remove connectionLog
  1608.      *
  1609.      * @param \App\Entity\Log\LogUser $connectionLog
  1610.      */
  1611.     public function removeConnectionLog(\App\Entity\Log\LogUser $connectionLog)
  1612.     {
  1613.         $this->connectionLogs->removeElement($connectionLog);
  1614.     }
  1615.     /**
  1616.      * Get connectionLogs
  1617.      *
  1618.      * @return \Doctrine\Common\Collections\Collection
  1619.      */
  1620.     public function getConnectionLogs()
  1621.     {
  1622.         return $this->connectionLogs;
  1623.     }
  1624.     
  1625.     /**
  1626.      * Add friend
  1627.      *
  1628.      * @param \App\Entity\Friend $friend
  1629.      *
  1630.      * @return User
  1631.      */
  1632.     public function addFriend(\App\Entity\Friend $friend)
  1633.     {
  1634.         $friend->setUser($this);
  1635.         $this->friends[] = $friend;
  1636.         return $this;
  1637.     }
  1638.     /**
  1639.      * Remove friend
  1640.      *
  1641.      * @param \App\Entity\Friend $friend
  1642.      */
  1643.     public function removeFriend(\App\Entity\Friend $friend)
  1644.     {
  1645.         $this->friends->removeElement($friend);
  1646.     }
  1647.     
  1648.     /**
  1649.      * Get friends
  1650.      *
  1651.      * @return \Doctrine\Common\Collections\Collection
  1652.      */
  1653.     public function getFriends()
  1654.     {
  1655.         return $this->friends;
  1656.     }
  1657.     
  1658.     /**
  1659.      * Add friendRequest
  1660.      *
  1661.      * @param \App\Entity\Friend $friendRequest
  1662.      *
  1663.      * @return User
  1664.      */
  1665.     public function addFriendRequest(\App\Entity\Friend $friendRequest)
  1666.     {
  1667.         $this->friendRequests[] = $friendRequest;
  1668.         return $this;
  1669.     }
  1670.     /**
  1671.      * Remove friendRequest
  1672.      *
  1673.      * @param \App\Entity\Friend $friendRequest
  1674.      */
  1675.     public function removeFriendRequest(\App\Entity\Friend $friendRequest)
  1676.     {
  1677.         $this->friendRequests->removeElement($friendRequest);
  1678.     }
  1679.     /**
  1680.      * Get friendRequests
  1681.      *
  1682.      * @return \Doctrine\Common\Collections\Collection
  1683.      */
  1684.     public function getFriendRequests()
  1685.     {
  1686.         return $this->friendRequests;
  1687.     }
  1688.     
  1689.     /**
  1690.      * Add followUser
  1691.      *
  1692.      * @param \App\Entity\UserFollow $followUser
  1693.      *
  1694.      * @return User
  1695.      */
  1696.     public function addFollowUser(\App\Entity\UserFollow $followUser)
  1697.     {
  1698.         $this->followUsers[] = $followUser;
  1699.         return $this;
  1700.     }
  1701.     /**
  1702.      * Remove followUser
  1703.      *
  1704.      * @param \App\Entity\UserFollow $followUser
  1705.      */
  1706.     public function removeFollowUser(\App\Entity\UserFollow $followUser)
  1707.     {
  1708.         $this->followUsers->removeElement($followUser);
  1709.     }
  1710.     /**
  1711.      * Get followUsers
  1712.      *
  1713.      * @return \Doctrine\Common\Collections\Collection
  1714.      */
  1715.     public function getFollowUsers()
  1716.     {
  1717.         return $this->followUsers;
  1718.     }
  1719.     
  1720.     /**
  1721.      * Add follower
  1722.      *
  1723.      * @param \App\Entity\UserFollow $follower
  1724.      *
  1725.      * @return User
  1726.      */
  1727.     public function addFollower(\App\Entity\UserFollow $follower)
  1728.     {
  1729.         $this->followers[] = $follower;
  1730.         return $this;
  1731.     }
  1732.     /**
  1733.      * Remove follower
  1734.      *
  1735.      * @param \App\Entity\UserFollow $follower
  1736.      */
  1737.     public function removeFollower(\App\Entity\UserFollow $follower)
  1738.     {
  1739.         $this->followers->removeElement($follower);
  1740.     }
  1741.     /**
  1742.      * Get followers
  1743.      *
  1744.      * @return \Doctrine\Common\Collections\Collection
  1745.      */
  1746.     public function getFollowers()
  1747.     {
  1748.         return $this->followers;
  1749.     }
  1750.     
  1751.     
  1752.     /********************************
  1753.         EncoderAwareInterface
  1754.     ********************************/
  1755.     /**
  1756.      * Tells whether user uses the legacy password encoding or the new one
  1757.      * 
  1758.      * @return boolean
  1759.      */
  1760.     public function hasLegacyPassword()
  1761.     {
  1762.         return null !== $this->oldPassword;
  1763.     }
  1764.     /**
  1765.      * {@inheritDoc}
  1766.      */
  1767.     public function getEncoderName()
  1768.     {
  1769.         if ($this->hasLegacyPassword()) {
  1770.             // User is configured with a legacy password, make use of the legacy encoder
  1771.             // configured in security.yml
  1772.             return 'legacy_encoder';
  1773.         }
  1774.         // User is configured with the default password system, make use of the default encoder
  1775.         return null;
  1776.     }
  1777.     /********************************
  1778.         
  1779.         SERIALIZE
  1780.     *********************************/
  1781.     
  1782.     /** @see \Serializable::serialize() */
  1783.     public function serialize()
  1784.     {
  1785.         return serialize(array(
  1786.             $this->id,
  1787.             $this->email,
  1788.             $this->password,
  1789.             $this->nickname,
  1790.             // see section on salt below
  1791.             // $this->salt,
  1792.         ));
  1793.     }
  1794.     /** @see \Serializable::unserialize() */
  1795.     public function unserialize($serialized)
  1796.     {
  1797.         list (
  1798.             $this->id,
  1799.             $this->email,
  1800.             $this->password,
  1801.             $this->nickname,
  1802.             // see section on salt below
  1803.             // $this->salt
  1804.         ) = unserialize($serialized);
  1805.     }
  1806.     
  1807.     public function eraseCredentials()
  1808.     {
  1809.     }
  1810.     
  1811.     public function getUsername()
  1812.     {
  1813.         return $this->email;
  1814.     }
  1815.     
  1816.     
  1817.     /**
  1818.      * Set avatar
  1819.      *
  1820.      * @param string $avatar
  1821.      *
  1822.      * @return User
  1823.      */
  1824.     public function setAvatar($avatar)
  1825.     {
  1826.         $this->avatar $avatar;
  1827.         return $this;
  1828.     }
  1829.     /**
  1830.      * Get avatar
  1831.      *
  1832.      * @return string
  1833.      */
  1834.     public function getAvatar()
  1835.     {
  1836.         return $this->avatar;
  1837.     }
  1838.     
  1839.     
  1840.     /**
  1841.      * Set urlAvatarForProvider
  1842.      *
  1843.      * @param string $urlAvatarForProvider
  1844.      *
  1845.      * @return User
  1846.      */
  1847.     public function setUrlAvatarForProvider($urlAvatarForProvider)
  1848.     {
  1849.         $this->urlAvatarForProvider $urlAvatarForProvider;
  1850.         return $this;
  1851.     }
  1852.     /**
  1853.      * Get urlAvatarForProvider
  1854.      *
  1855.      * @return string
  1856.      */
  1857.     public function getUrlAvatarForProvider()
  1858.     {
  1859.         return $this->urlAvatarForProvider;
  1860.     }
  1861.     
  1862.     
  1863.     public function getLinkAvatar()
  1864.     {
  1865.         
  1866.         if($this->provider == 'facebook'){
  1867.             if($this->getUrlAvatarForProvider())
  1868.                 return $this->getUrlAvatarForProvider();
  1869.         }else{
  1870.             if($this->getAvatar()){
  1871.                 if(file_exists($this->getUploadAvatarRootDir().$this->getAvatar()))
  1872.                     return $this->getAvatarDir().$this->getAvatar();
  1873.             }
  1874.         }
  1875.         
  1876.         
  1877.         if($this->player)
  1878.             return '/assets/images/common/defaultAvatar.png';
  1879.         else if($this->club)
  1880.             return '/assets/images/common/defaultAvatarClub.png';
  1881.         else if($this->pro)
  1882.             return '/assets/images/common/defaultAvatarPro.png';
  1883.         
  1884.         
  1885.         return '/assets/images/common/defaultAvatar.png';
  1886.     }
  1887.     
  1888.     public function getAbsolutePathAvatar()
  1889.     {
  1890.         if($this->getAvatar()){
  1891.             if(file_exists($this->getUploadAvatarRootDir().$this->getAvatar()))
  1892.                 return $this->getUploadAvatarRootDir().$this->getAvatarPath();
  1893.             else
  1894.                 return null;
  1895.         }else{
  1896.             return null;
  1897.         }
  1898.     }
  1899.     
  1900.     
  1901.     /**
  1902.      * Sets avatarFile.
  1903.      *
  1904.      * @param UploadedFile $file
  1905.      */
  1906.     public function setAvatarFile(UploadedFile $file null)
  1907.     {
  1908.         $this->avatarFile $file;
  1909.         $this->setDateUpdated(new \DateTime());
  1910.     }
  1911.     
  1912.     /**
  1913.      * Get avatarFile.
  1914.      *
  1915.      * @return UploadedFile
  1916.      */
  1917.     public function getAvatarFile()
  1918.     {
  1919.         return $this->avatarFile;
  1920.     }
  1921.     
  1922.     
  1923.     /**
  1924.      * Set distance
  1925.      *
  1926.      * @param float $distance
  1927.      *
  1928.      * @return User
  1929.      */
  1930.     public function setDistance($distance)
  1931.     {
  1932.         $this->distance str_replace(",""."$distance);
  1933.         return $this;
  1934.     }
  1935.     /**
  1936.      * Get distance
  1937.      *
  1938.      * @return float
  1939.      */
  1940.     public function getDistance()
  1941.     {
  1942.         return $this->distance;
  1943.     }
  1944.     
  1945.     /**
  1946.      * Get stringDistance
  1947.      *
  1948.      * @return string
  1949.      */
  1950.     public function getStringDistance()
  1951.     {
  1952.         if($this->distance 1000){
  1953.             return sprintf("%0.2f km"$this->distance/1000);
  1954.         }else{
  1955.             return sprintf("%0.2f m"$this->distance);
  1956.         }
  1957.     }
  1958.     
  1959.     
  1960.     public function isEqualTo(UserInterface $user)
  1961.     {
  1962.         /*if (!$user instanceof Users) {
  1963.             return false;
  1964.         }*/
  1965.         
  1966.         if ($this->id !== $user->getId()) {
  1967.             return false;
  1968.         }
  1969.         
  1970.         if ($this->email !== $user->getEmail()) {
  1971.             return false;
  1972.         }
  1973.         /*if ($this->provider=='email' && $this->password !== $user->getPassword()) {
  1974.             return false;
  1975.         }*/
  1976.         return true;
  1977.     }
  1978.     
  1979.     
  1980.     /***********************
  1981.      * Lifecycle Callbacks
  1982.      ***********************/
  1983.     /**
  1984.      *
  1985.      * @ORM\PrePersist()
  1986.      * @ORM\PreUpdate()
  1987.      */
  1988.     public function preUpdate()
  1989.     {
  1990.         $this->setDateUpdated(new \DateTime());
  1991.         if($this->getLng() && $this->getLat())
  1992.             $this->setCoordinates('SRID=4326;POINT(' $this->getLng() . ' ' $this->getLat() . ')');
  1993.         
  1994.     }
  1995.     
  1996.     /**
  1997.      * Called before saving the entity
  1998.      * 
  1999.      * @ORM\PrePersist()
  2000.      * @ORM\PreUpdate()
  2001.      */
  2002.     public function preUpload()
  2003.     {   
  2004.         if (null !== $this->avatarFile) {
  2005.             // do whatever you want to generate a unique name
  2006.             $filename sha1(uniqid(mt_rand(), true));
  2007.             //$this->avatar = $filename.'.'.$this->avatarFile->guessExtension();
  2008.             $this->avatar $filename.'.'.$this->avatarFile->getClientOriginalExtension();
  2009.             
  2010.             $this->setDateUpdated(new \DateTime());
  2011.         }
  2012.     }
  2013.     
  2014.     /**
  2015.      * Called before entity removal
  2016.      *
  2017.      * @ORM\PreRemove()
  2018.      */
  2019.     public function removeUpload()
  2020.     {
  2021.         if ($file $this->getAbsolutePathAvatar()) {
  2022.             unlink($file); 
  2023.         }
  2024.     }
  2025.     
  2026.     /**
  2027.      * Called after entity persistence
  2028.      *
  2029.      * @ORM\PostPersist()
  2030.      * @ORM\PostUpdate()
  2031.      */
  2032.     public function upload()
  2033.     {
  2034.         // The file property can be empty if the field is not required
  2035.         if (null === $this->avatarFile) {
  2036.             return;
  2037.         }
  2038.     
  2039.         // Use the original file name here but you should
  2040.         // sanitize it at least to avoid any security issues
  2041.     
  2042.         // move takes the target directory and then the
  2043.         // target filename to move to
  2044.         $this->avatarFile->move(
  2045.             $this->getUploadAvatarRootDir(),
  2046.             $this->avatar
  2047.         );
  2048.     
  2049.         // Set the path property to the filename where you've saved the file
  2050.         //$this->path = $this->file->getClientOriginalName();
  2051.     
  2052.         // Clean up the file property as you won't need it anymore
  2053.         $this->avatarFile null;
  2054.     }
  2055.     
  2056.     
  2057.     
  2058.     
  2059.     
  2060.     /***********************
  2061.      * OTHER FUNCTION
  2062.      ***********************/
  2063.      
  2064.      public function isFriend(User $target){
  2065.         foreach($this->getFriends() as $friend){
  2066.             if($friend->getFriend()->getId() == $target->getId()){
  2067.                 if($friend->getDateAccept())
  2068.                     return true;
  2069.             }
  2070.         }
  2071.         
  2072.         foreach($this->getFriendRequests() as $friend){
  2073.             if($friend->getUser()->getId() == $target->getId()){
  2074.                 if($friend->getDateAccept())
  2075.                     return true;
  2076.             }
  2077.         }
  2078.         
  2079.         return false;
  2080.     }
  2081.     
  2082.     public function isFriendRequestSent(User $target){
  2083.         foreach($this->getFriends() as $friend){
  2084.             if($friend->getFriend()->getId() == $target->getId()){
  2085.                 if(!$friend->getDateAccept())
  2086.                     return true;
  2087.             }
  2088.         }
  2089.         
  2090.         return false;
  2091.     }
  2092.     
  2093.     public function isFriendRequestReceived(User $target){
  2094.         foreach($this->getFriendRequests() as $friend){
  2095.             if($friend->getUser()->getId() == $target->getId()){
  2096.                 if(!$friend->getDateAccept())
  2097.                     return $friend->getId();
  2098.             }
  2099.         }
  2100.         
  2101.         return false;
  2102.     }
  2103.     
  2104.     public function getFriendRequestReceived(User $target){
  2105.         foreach($this->getFriendRequests() as $friend){
  2106.             if($friend->getUser()->getId() == $target->getId()){
  2107.                 if(!$friend->getDateAccept())
  2108.                     return $friend;
  2109.             }
  2110.         }
  2111.         
  2112.         return false;
  2113.     }
  2114.     
  2115.     public function nbRequestFriend(){
  2116.         $nb 0;
  2117.         foreach($this->getFriendRequests() as $friend){
  2118.             if(!$friend->getDateAccept())
  2119.                 $nb++;
  2120.         }
  2121.         
  2122.         return $nb;
  2123.     }
  2124.     
  2125.     public function getRequestFriend(){
  2126.         $arrayReturn = array();
  2127.         foreach($this->getFriendRequests() as $friend){
  2128.             if(!$friend->getDateAccept())
  2129.                 $arrayReturn[] = $friend;
  2130.         }
  2131.         
  2132.         return $arrayReturn;
  2133.     }
  2134.     
  2135.     
  2136.     public function getAllFriends(){
  2137.         $arrayReturn = array();
  2138.         foreach($this->getFriendRequests() as $friend){
  2139.             if($friend->getDateAccept())
  2140.                 $arrayReturn[] = $friend->getUser();
  2141.         }
  2142.         
  2143.         foreach($this->getFriends() as $friend){
  2144.             if($friend->getDateAccept())
  2145.                 $arrayReturn[] = $friend->getFriend();
  2146.         }
  2147.         
  2148.         return $arrayReturn;
  2149.     }
  2150.     
  2151.     public function getAllUsersInvitationSent(){
  2152.         $arrayReturn = array();
  2153.         foreach($this->getFriends() as $friend){
  2154.             if(!$friend->getDateAccept())
  2155.                 $arrayReturn[] = $friend->getFriend();
  2156.         }
  2157.         
  2158.         return $arrayReturn;
  2159.     }
  2160.     
  2161.     public function getNbUnreadMessageForUserInteract(User $userInteract){
  2162.         
  2163.         $nb 0;
  2164.         
  2165.         foreach($this->getReceivedMessages() as $message){
  2166.             if($message->getSender()->getId() == $userInteract->getId() && $message->getRead() == FALSE){
  2167.                 $nb++;
  2168.             }
  2169.         }
  2170.         
  2171.         return $nb;
  2172.     }
  2173.     
  2174.     
  2175.     public function isFollowed(User $target){
  2176.         foreach($this->getFollowUsers() as $followUser){
  2177.             if($followUser->getUserFollowed()->getId() == $target->getId()){
  2178.                 return true;
  2179.             }
  2180.         }
  2181.         
  2182.         return false;
  2183.         
  2184.     }
  2185.     
  2186.     public function getAllUsersFollowed(){
  2187.         $arrayReturn = array();
  2188.         foreach($this->getFollowUsers() as $followUser){
  2189.             $arrayReturn[] = $followUser->getUserFollowed();
  2190.         }
  2191.         
  2192.         return $arrayReturn;
  2193.     }
  2194.     
  2195.     public function getListIdFriends()
  2196.     {
  2197.         
  2198.         $listFriendId = array();
  2199.         foreach($this->getAllFriends() as $friend){
  2200.             $listFriendId[] = $friend->getId();
  2201.         }
  2202.         
  2203.         return $listFriendId;
  2204.     }
  2205.     
  2206.     public function getListIdFollowed()
  2207.     {
  2208.         $listIds = array();
  2209.         foreach($this->getAllUsersFollowed() as $userFollowed){
  2210.             $listIds[] = $userFollowed->getId();
  2211.         }
  2212.         
  2213.         return $listIds;
  2214.     }
  2215.     
  2216.     public function getListIdFriendsAndFollowed()
  2217.     {
  2218.         $listIds = array();
  2219.         foreach($this->getAllFriends() as $friend){
  2220.             $listIds[] = $friend->getId();
  2221.         }
  2222.         foreach($this->getAllUsersFollowed() as $userFollowed){
  2223.             $listIds[] = $userFollowed->getId();
  2224.         }
  2225.         
  2226.         return $listIds;
  2227.     }
  2228.     
  2229.     
  2230.     public function getUploadAvatarRootDir(){
  2231.         
  2232.         $logoDir __DIR__ '/../../public/assets/profiles/'.$this->getId().'/avatar/';
  2233.         
  2234.         $fs = new Filesystem();
  2235.         if ($fs->exists($logoDir) == false) {
  2236.                 $fs->mkdir($logoDir);
  2237.         }
  2238.         
  2239.         return $logoDir;
  2240.     }
  2241.     
  2242.     public function getAvatarDir()
  2243.     {
  2244.         return '/assets/profiles/'.$this->getId().'/avatar/';
  2245.     }
  2246.     
  2247.     public function getCountryName(){
  2248.         //return Intl::getRegionBundle()->getCountryName($this->getCountry());
  2249.         if(!$this->getCountry() || $this->getCountry() == "" || $this->getCountry() == "ITN")
  2250.             return "";
  2251.         
  2252.         return Countries::getName($this->getCountry());
  2253.     }
  2254.     
  2255.     
  2256.     public function getSimpleWithTypeArrayForJson($schemeAndBaseURL$userTools null$currentUser null){
  2257.         $array $this->getSimpleArrayForJson($schemeAndBaseURL);
  2258.         
  2259.         if($this->getPlayer()){
  2260.             $array['player'] = $this->getPlayer()->getArrayForJson($userTools$currentUser);
  2261.         }else if($this->getClub()){
  2262.             $array['club'] = $this->getClub()->getArrayForJson();
  2263.         }else if($this->getPro()){
  2264.             $array['pro'] = $this->getPro()->getArrayForJson();
  2265.         }
  2266.             
  2267.         return $array;
  2268.     }
  2269.     
  2270.     
  2271.     public function hasInvoice(){
  2272.         if($this->getFeedElements()){
  2273.             foreach($this->getFeedElements() as $feed){
  2274.                 if($feed->getTransaction()){
  2275.                     return true;
  2276.                 }
  2277.             }
  2278.         }
  2279.         
  2280.         return false;
  2281.     }
  2282.     
  2283.     
  2284.     public function getCustomerCode(){
  2285.         return "TAM".sprintf("%05d"$this->getId());
  2286.     }
  2287.     
  2288.     
  2289.     public function getSimpleArrayForJson($schemeAndBaseURL$userTools null$currentUser null){
  2290.         $array = array();
  2291.         $array['id'] = $this->getId();
  2292.         $array['civility'] = $this->getCivility();
  2293.         if($this->getNickname())
  2294.             $array['nickname'] = $this->getNickname();
  2295.         else
  2296.             $array['nickname'] = "Not defined";
  2297.         $array['lastname'] = $this->getLastname();
  2298.         $array['firstname'] = $this->getFirstname();
  2299.         $array['email'] = $this->getEmail();
  2300.         $array['address'] = $this->getAddress();
  2301.         $array['zipcode'] = $this->getZipcode();
  2302.         $array['city'] = $this->getCity();
  2303.         $array['country'] = $this->getCountry();
  2304.         $array['countryName'] = $this->getCountryName();
  2305.         
  2306.         $array['lat'] = $this->getLat();
  2307.         $array['lng'] = $this->getLng();
  2308.         
  2309.         $array['distance'] = $this->getDistance();
  2310.         $array['distanceLabel'] = $this->getStringDistance();
  2311.         
  2312.         if($this->getAvatar()){
  2313.             if($this->getProvider() == 'email')
  2314.                 $array['avatarURL'] = $schemeAndBaseURL.$this->getLinkAvatar();
  2315.             else
  2316.                 $array['avatarURL'] = $this->getLinkAvatar();
  2317.         }
  2318.         
  2319.         $array['isPlayer'] = $this->getPlayer() ? true false;
  2320.         $array['isClub'] = $this->getClub() ? true false;
  2321.         $array['isPro'] = $this->getPro() ? true false;
  2322.             
  2323.             
  2324.         return $array;
  2325.     }
  2326.     
  2327.     public function getArrayForJson($schemeAndBaseURL$userTools null$currentUser null$friend false){
  2328.         $array = array();
  2329.         $array['id'] = $this->getId();
  2330.         $array['civility'] = $this->getCivility();
  2331.         $array['nickname'] = $this->getNickname();
  2332.         $array['lastname'] = $this->getLastname();
  2333.         $array['firstname'] = $this->getFirstname();
  2334.         $array['email'] = $this->getEmail();
  2335.         $array['address'] = $this->getAddress();
  2336.         $array['zipcode'] = $this->getZipcode();
  2337.         $array['city'] = $this->getCity();
  2338.         $array['country'] = $this->getCountry();
  2339.         $array['countryName'] = $this->getCountryName();
  2340.         
  2341.         $array['lat'] = $this->getLat();
  2342.         $array['lng'] = $this->getLng();
  2343.         if($this->getAvatar()){
  2344.             if($this->getProvider() == 'email')
  2345.                 $array['avatarURL'] = $schemeAndBaseURL.$this->getLinkAvatar();
  2346.             else
  2347.                 $array['avatarURL'] = $this->getLinkAvatar();
  2348.         }
  2349.         if($this->getPlayer()){
  2350.             $array['player'] = $this->getPlayer()->getArrayForJson($userTools$currentUser);
  2351.             if($this->getAllFriends() && $friend === false){
  2352.                 $array['NBfriends'] = count($this->getAllFriends());
  2353.                 foreach($this->getAllFriends() as $friend){
  2354.                     $array['friends'][] = $friend->getSimpleWithTypeArrayForJson($schemeAndBaseURL$userTools$currentUsertrue);
  2355.                 }
  2356.             }
  2357.             
  2358.             if($this->getAllUsersInvitationSent()){
  2359.                 $array['NBInvitationsSent'] = count($this->getAllUsersInvitationSent());
  2360.                 foreach($this->getAllUsersInvitationSent() as $friend){
  2361.                     $array['invitationSent'][] = $friend->getSimpleWithTypeArrayForJson($schemeAndBaseURL$userTools$currentUsertrue);
  2362.                 }
  2363.             }
  2364.             
  2365.             if($this->getRequestFriend()){
  2366.                 $array['NBRequestFriendReceived'] = count($this->getRequestFriend());
  2367.                 foreach($this->getRequestFriend() as $request){
  2368.                     $array['requestFriendReceived'][] = $request->getUser()->getSimpleWithTypeArrayForJson($schemeAndBaseURL$userTools$currentUsertrue);
  2369.                 }
  2370.             }
  2371.         
  2372.             
  2373.         }
  2374.         
  2375.         if($this->getClub() || $this->getPro()){
  2376.             if($this->getClub())
  2377.                 $array['club'] = $this->getClub()->getArrayForJson();
  2378.             if($this->getPro())
  2379.                 $array['pro'] = $this->getPro()->getArrayForJson();
  2380.             if($this->getFollowers()){
  2381.                 $array['NBFollowers'] = count($this->getFollowers());
  2382.                 foreach($this->getFollowers() as $follower){
  2383.                     $array['followers'][] = $follower->getUser()->getSimpleWithTypeArrayForJson($schemeAndBaseURL$userTools$currentUsertrue);
  2384.                 }
  2385.             }
  2386.         }
  2387.         
  2388.         if($this->getAllUsersFollowed()){
  2389.             $array['NBFollowUsers'] = count($this->getAllUsersFollowed());
  2390.             foreach($this->getAllUsersFollowed() as $followUser){
  2391.                 $array['followUsers'][] = $followUser->getSimpleArrayForJson($schemeAndBaseURL$userTools$currentUsertrue);
  2392.             }
  2393.         }
  2394.         
  2395.         $array['isPlayer'] = $this->getPlayer() ? true false;
  2396.         $array['isClub'] = $this->getClub() ? true false;
  2397.         $array['isPro'] = $this->getPro() ? true false;
  2398.         
  2399.         return $array;
  2400.         
  2401.     }    
  2402.     
  2403.     
  2404.     public function getJsonData(){
  2405.         
  2406.         
  2407.         return json_encode($this->getArrayForJson());
  2408.         
  2409.     }
  2410.     
  2411.     public function getFriendInfoArrayForJson($schemeAndBaseURL){
  2412.         $array = array();
  2413.         $array['id'] = $this->getId();
  2414.         $array['civility'] = $this->getCivility();
  2415.         $array['nickname'] = $this->getNickname();
  2416.         $array['lastname'] = $this->getLastname();
  2417.         $array['firstname'] = $this->getFirstname();
  2418.         $array['email'] = $this->getEmail();
  2419.         $array['address'] = $this->getAddress();
  2420.         $array['zipcode'] = $this->getZipcode();
  2421.         $array['city'] = $this->getCity();
  2422.         $array['country'] = $this->getCountry();
  2423.         $array['countryName'] = $this->getCountryName();
  2424.         
  2425.         $array['lat'] = $this->getLat();
  2426.         $array['lng'] = $this->getLng();
  2427.         
  2428.         if($this->getAvatar()){
  2429.             if($this->getProvider() == 'email')
  2430.                 $array['avatarURL'] = $schemeAndBaseURL.$this->getLinkAvatar();
  2431.             else
  2432.                 $array['avatarURL'] = $this->getLinkAvatar();
  2433.         }
  2434.             
  2435.         if($this->getTams()){
  2436.             foreach($this->getTams() as $tam){
  2437.                 $array['tams'][] = $tam->getArrayForJson($schemeAndBaseURL);
  2438.             }
  2439.         }
  2440.         
  2441.         $array['isPlayer'] = $this->getPlayer() ? true false;
  2442.         $array['isClub'] = $this->getClub() ? true false;
  2443.         $array['isPro'] = $this->getPro() ? true false;
  2444.         
  2445.         return $array;
  2446.     }
  2447.     
  2448.     
  2449.     
  2450.     public function updateFromJson($jsonObject){
  2451.         $this->setNickname($jsonObject->nickname);
  2452.         $this->setLastname($jsonObject->lastname);
  2453.         $this->setFirstname($jsonObject->firstname);
  2454.         $this->setEmail($jsonObject->email);
  2455.         $this->setAddress($jsonObject->address);
  2456.         $this->setZipcode($jsonObject->zipcode);
  2457.         $this->setCity($jsonObject->city);
  2458.         $this->setCountry(strtoupper($jsonObject->country));    
  2459.     }
  2460.     
  2461.     
  2462. }