src/Entity/Player/Player.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Player;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. /**
  7.  * Player
  8.  *
  9.  * @ORM\Table(name="tam_players")
  10.  * @ORM\Entity(repositoryClass="App\Repository\Player\PlayerRepository")
  11.  * @ORM\HasLifecycleCallbacks
  12.  */
  13. class Player
  14. {
  15.     /**
  16.      * @var int
  17.      *
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="IDENTITY")
  21.      */
  22.     private $id;
  23.     
  24.     /**
  25.      * @ORM\OneToOne(targetEntity="App\Entity\User", inversedBy="player", cascade={"persist", "remove"})
  26.      * @ORM\JoinColumn(name="tam_user", referencedColumnName="id",  onDelete="CASCADE", nullable=false)
  27.      */
  28.     private $user;
  29.     
  30.     /**
  31.      * @var string
  32.      *
  33.      * @ORM\Column(name="gender", type="string", length=255, nullable=true)
  34.      */
  35.     private $gender;
  36.     
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(name="gimmick", type="text", length=255, nullable=true)
  41.      */
  42.     private $gimmick;
  43.     
  44.     /**
  45.      * @var \DateTime
  46.      *
  47.      * @ORM\Column(name="birthdate", type="date", nullable=true)
  48.      */
  49.     private $birthdate;
  50.     
  51.     
  52.     /**
  53.      * @var \rankingSystem
  54.      *
  55.      * @ORM\ManyToOne(targetEntity="\App\Entity\Ranking\RankingSystem", inversedBy="rankingPlayers")
  56.      * @ORM\JoinColumns({
  57.      *   @ORM\JoinColumn(name="ranking_system", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  58.      * })
  59.      */
  60.     private $rankingSystem;
  61.     
  62.     /**
  63.      * @var \ranking
  64.      *
  65.      * @ORM\ManyToOne(targetEntity="\App\Entity\Ranking\Ranking", inversedBy="currentRankingPlayers")
  66.      * @ORM\JoinColumns({
  67.      *   @ORM\JoinColumn(name="current_ranking", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  68.      * })
  69.      */
  70.     private $currentRanking;
  71.     
  72.     /**
  73.      * @var \rankingCountry
  74.      *
  75.      * @ORM\ManyToOne(targetEntity="\App\Entity\Ranking\Ranking", inversedBy="bestRankingPlayers")
  76.      * @ORM\JoinColumns({
  77.      *   @ORM\JoinColumn(name="best_ranking", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  78.      * })
  79.      */
  80.     private $bestRanking;
  81.     
  82.     /**
  83.      * @var \DateTime
  84.      *
  85.      * @ORM\Column(name="best_ranking_date", type="date", nullable=true)
  86.      */
  87.     private $bestRankingDate;
  88.     
  89.     /**
  90.      * @var string
  91.      *
  92.      * @ORM\Column(name="hand", type="string", length=255, nullable=true)
  93.      */
  94.     private $hand;
  95.     
  96.     /**
  97.      * @var float
  98.      *
  99.      * @ORM\Column(name="game_level", type="float", precision=10, scale=0, nullable=true)
  100.      */
  101.     private $gameLevel;
  102.     
  103.     /**
  104.      * @var \App\Entity\Player\PlayerType
  105.      *
  106.      * @ORM\ManyToOne(targetEntity="\App\Entity\Player\PlayerType", inversedBy="players")
  107.      * @ORM\JoinColumns({
  108.      *   @ORM\JoinColumn(name="player_type", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  109.      * })
  110.      */
  111.     private $playerType;
  112.     
  113.     /**
  114.      * @var \App\Entity\Brand\BrandRacket
  115.      *
  116.      * @ORM\ManyToOne(targetEntity="\App\Entity\Brand\BrandRacket", fetch="EAGER", inversedBy="players")
  117.      * @ORM\JoinColumns({
  118.      *   @ORM\JoinColumn(name="brand_racket", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  119.      * })
  120.      */
  121.     private $brandRacket;
  122.     
  123.      /**
  124.      * @var \App\Entity\Brand\BrandShoe
  125.      *
  126.      * @ORM\ManyToOne(targetEntity="\App\Entity\Brand\BrandShoe", fetch="EAGER", inversedBy="players")
  127.      * @ORM\JoinColumns({
  128.      *   @ORM\JoinColumn(name="brand_shoe", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  129.      * })
  130.      */
  131.     private $brandShoe;
  132.     
  133.     /**
  134.      * @var integer
  135.      *
  136.      * @ORM\Column(name="nb_play_by_week", type="integer", options={"default": 0}, nullable=true)
  137.      */
  138.     private $nbPlayByWeek;
  139.     
  140.      /**
  141.      * @var \App\Entity\Player\PlayerNbTournamentByYear
  142.      *
  143.      * @ORM\ManyToOne(targetEntity="\App\Entity\Player\PlayerNbTournamentByYear", fetch="EAGER", inversedBy="players")
  144.      * @ORM\JoinColumns({
  145.      *   @ORM\JoinColumn(name="nb_tournament_by_year", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  146.      * })
  147.      */
  148.     private $nbTournamentByYear;
  149.     
  150.     /**
  151.      * @var string
  152.      *
  153.      * @ORM\Column(name="favorite_player_m", type="string", length=255, nullable=true)
  154.      */
  155.     private $favoritePlayerM;
  156.     
  157.     /**
  158.      * @var string
  159.      *
  160.      * @ORM\Column(name="favorite_player_f", type="string", length=255, nullable=true)
  161.      */
  162.     private $favoritePlayerF;
  163.     
  164.     /**
  165.      * @var string
  166.      *
  167.      * @ORM\Column(name="best_performance", type="string", length=255, nullable=true)
  168.      */
  169.     private $bestPerformance;
  170.     
  171.     /**
  172.      * @var \DateTime
  173.      *
  174.      * @ORM\Column(name="best_performance_date", type="date", nullable=true)
  175.      */
  176.     private $bestPerformanceDate;
  177.     
  178.     /**
  179.      * @var string
  180.      *
  181.      * @ORM\Column(name="best_match_viewed", type="text", nullable=true)
  182.      */
  183.     private $bestMatchViewed;
  184.     
  185.     /**
  186.      * @var \App\Entity\Club\Club
  187.      *
  188.      * @ORM\ManyToOne(targetEntity="\App\Entity\Club\Club", fetch="EAGER", inversedBy="players")
  189.      * @ORM\JoinColumns({
  190.      *   @ORM\JoinColumn(name="club", referencedColumnName="id", onDelete="SET NULL", nullable=true)
  191.      * })
  192.      */
  193.     private $club;
  194.     
  195.     /**
  196.      * @var string
  197.      *
  198.      * @ORM\Column(name="other_club", type="string", length=255, nullable=true)
  199.      */
  200.     private $otherClub;
  201.     
  202.     /**
  203.      * @var ArrayCollection
  204.      *
  205.      * @ORM\ManyToMany(targetEntity="\App\Entity\Player\PlayerWish", inversedBy="players")
  206.      * @ORM\JoinTable(name="tam_user_player_wish")
  207.      */
  208.     private $wishes;
  209.     
  210.     /**
  211.      * @var ArrayCollection
  212.      *
  213.      * @ORM\ManyToMany(targetEntity="\App\Entity\Player\PlayerAvailability", inversedBy="players")
  214.      * @ORM\JoinTable(name="tam_user_player_availability")
  215.      */
  216.     private $availabilities;
  217.     
  218.     
  219.     public function __construct()
  220.     {
  221.         $this->wishes = new ArrayCollection();
  222.         $this->availabilities = new ArrayCollection();
  223.     }
  224.     /**
  225.      * Get id
  226.      *
  227.      * @return int
  228.      */
  229.     public function getId()
  230.     {
  231.         return $this->id;
  232.     }
  233.     
  234.     /**
  235.      * Set User
  236.      *
  237.      * @param \App\Entity\User $user
  238.      *
  239.      * @return Player
  240.      */
  241.     public function setUser(\App\Entity\User $user)
  242.     {
  243.         
  244.         $this->user $user;
  245.         $user->setPlayer($this);
  246.         return $this;
  247.     }
  248.     /**
  249.      * Get user
  250.      *
  251.      * @return \App\Entity\User
  252.      */
  253.     public function getUser()
  254.     {
  255.         return $this->user;
  256.     }
  257.     
  258.     /**
  259.      * Set gender
  260.      *
  261.      * @param string $gender
  262.      *
  263.      * @return Player
  264.      */
  265.     public function setGender($gender)
  266.     {
  267.         $this->gender $gender;
  268.         return $this;
  269.     }
  270.     /**
  271.      * Get gender
  272.      *
  273.      * @return string
  274.      */
  275.     public function getGender()
  276.     {
  277.         return $this->gender;
  278.     }
  279.     
  280.     /**
  281.      * Set gimmick
  282.      *
  283.      * @param string $gimmick
  284.      *
  285.      * @return Player
  286.      */
  287.     public function setGimmick($gimmick)
  288.     {
  289.         $this->gimmick $gimmick;
  290.         return $this;
  291.     }
  292.     /**
  293.      * Get gimmick
  294.      *
  295.      * @return string
  296.      */
  297.     public function getGimmick()
  298.     {
  299.         return $this->gimmick;
  300.     }
  301.     
  302.     /**
  303.      * Set birthdate
  304.      *
  305.      * @param \DateTime $birthdate
  306.      *
  307.      * @return Player
  308.      */
  309.     public function setBirthdate($birthdate)
  310.     {
  311.         $this->birthdate $birthdate;
  312.         return $this;
  313.     }
  314.     /**
  315.      * Get birthdate
  316.      *
  317.      * @return \DateTime
  318.      */
  319.     public function getBirthdate()
  320.     {
  321.         return $this->birthdate;
  322.     }
  323.     
  324.     
  325.     /**
  326.      * Set rankingSystem
  327.      *
  328.      * @param \App\Entity\Ranking\RankingSystem $rankingSystem
  329.      *
  330.      * @return Player
  331.      */
  332.     public function setRankingSystem(\App\Entity\Ranking\RankingSystem $rankingSystem)
  333.     {
  334.         $this->rankingSystem $rankingSystem;
  335.         return $this;
  336.     }
  337.     /**
  338.      * Get rankingSystem
  339.      *
  340.      * @return \App\Entity\Ranking\RankingSystem
  341.      */
  342.     public function getRankingSystem()
  343.     {
  344.         return $this->rankingSystem;
  345.     }
  346.     
  347.     /**
  348.      * Set currentRanking
  349.      *
  350.      * @param \App\Entity\Ranking\Ranking $currentRanking
  351.      *
  352.      * @return Player
  353.      */
  354.     public function setCurrentRanking(\App\Entity\Ranking\Ranking $currentRanking)
  355.     {
  356.         $this->currentRanking $currentRanking;
  357.         return $this;
  358.     }
  359.     /**
  360.      * Get currentRanking
  361.      *
  362.      * @return \App\Entity\Ranking\Ranking
  363.      */
  364.     public function getCurrentRanking()
  365.     {
  366.         return $this->currentRanking;
  367.     }
  368.     
  369.     /**
  370.      * Set bestRanking
  371.      *
  372.      * @param \App\Entity\Ranking\Ranking $bestRanking
  373.      *
  374.      * @return Player
  375.      */
  376.     public function setBestRanking(\App\Entity\Ranking\Ranking $bestRanking)
  377.     {
  378.         $this->bestRanking $bestRanking;
  379.         return $this;
  380.     }
  381.     /**
  382.      * Get bestRanking
  383.      *
  384.      * @return \App\Entity\Ranking\Ranking
  385.      */
  386.     public function getBestRanking()
  387.     {
  388.         return $this->bestRanking;
  389.     }
  390.     
  391.     /**
  392.      * Set bestRankingDate
  393.      *
  394.      * @param \DateTime $bestRankingDate
  395.      *
  396.      * @return Player
  397.      */
  398.     public function setBestRankingDate($bestRankingDate)
  399.     {
  400.         $this->bestRankingDate $bestRankingDate;
  401.         return $this;
  402.     }
  403.     /**
  404.      * Get bestRankingDate
  405.      *
  406.      * @return \DateTime
  407.      */
  408.     public function getBestRankingDate()
  409.     {
  410.         return $this->bestRankingDate;
  411.     }
  412.     
  413.     /**
  414.      * Set hand
  415.      *
  416.      * @param string $hand
  417.      *
  418.      * @return Player
  419.      */
  420.     public function setHand($hand)
  421.     {
  422.         $this->hand $hand;
  423.         return $this;
  424.     }
  425.     /**
  426.      * Get hand
  427.      *
  428.      * @return string
  429.      */
  430.     public function getHand()
  431.     {
  432.         return $this->hand;
  433.     }
  434.     
  435.     /**
  436.      * Set gameLevel
  437.      *
  438.      * @param float $gameLevel
  439.      *
  440.      * @return Player
  441.      */
  442.     public function setGameLevel($gameLevel)
  443.     {
  444.         if($gameLevel == "")
  445.             $this->gameLevel null;
  446.         else
  447.             $this->gameLevel str_replace(",""."$gameLevel);
  448.         return $this;
  449.     }
  450.     /**
  451.      * Get gameLevel
  452.      *
  453.      * @return float
  454.      */
  455.     public function getGameLevel()
  456.     {
  457.         return $this->gameLevel;
  458.     }
  459.     
  460.     /**
  461.      * Set playerType
  462.      *
  463.      * @param PlayerType $playerType
  464.      *
  465.      * @return Player
  466.      */
  467.     public function setPlayerType($playerType)
  468.     {
  469.         $this->playerType $playerType;
  470.         return $this;
  471.     }
  472.     /**
  473.      * Get playerType
  474.      *
  475.      * @return PlayerType
  476.      */
  477.     public function getPlayerType()
  478.     {
  479.         return $this->playerType;
  480.     }
  481.     
  482.     /**
  483.      * Set brandRacket
  484.      *
  485.      * @param RankingSystem $brandRacket
  486.      *
  487.      * @return Player
  488.      */
  489.     public function setBrandRacket($brandRacket)
  490.     {
  491.         $this->brandRacket $brandRacket;
  492.         return $this;
  493.     }
  494.     /**
  495.      * Get brandRacket
  496.      *
  497.      * @return BrandRacket
  498.      */
  499.     public function getBrandRacket()
  500.     {
  501.         return $this->brandRacket;
  502.     }
  503.     
  504.     /**
  505.      * Set brandShoe
  506.      *
  507.      * @param RankingSystem $brandShoe
  508.      *
  509.      * @return Player
  510.      */
  511.     public function setBrandShoe($brandShoe)
  512.     {
  513.         $this->brandShoe $brandShoe;
  514.         return $this;
  515.     }
  516.     /**
  517.      * Get brandShoe
  518.      *
  519.      * @return BrandShoe
  520.      */
  521.     public function getBrandShoe()
  522.     {
  523.         return $this->brandShoe;
  524.     }
  525.     
  526.     /**
  527.      * Set nbPlayByWeek
  528.      *
  529.      * @param integer $nbPlayByWeek
  530.      *
  531.      * @return Player
  532.      */
  533.     public function setNbPlayByWeek($nbPlayByWeek)
  534.     {
  535.         $this->nbPlayByWeek $nbPlayByWeek;
  536.         return $this;
  537.     }
  538.     /**
  539.      * Get nbPlayByWeek
  540.      *
  541.      * @return integer
  542.      */
  543.     public function getNbPlayByWeek()
  544.     {
  545.         return $this->nbPlayByWeek;
  546.     }
  547.     
  548.     /**
  549.      * Set nbTournamentByYear
  550.      *
  551.      * @param PlayerNbTournamentByYear $nbTournamentByYear
  552.      *
  553.      * @return Player
  554.      */
  555.     public function setNbTournamentByYear($nbTournamentByYear)
  556.     {
  557.         $this->nbTournamentByYear $nbTournamentByYear;
  558.         return $this;
  559.     }
  560.     /**
  561.      * Get nbTournamentByYear
  562.      *
  563.      * @return integer
  564.      */
  565.     public function getNbTournamentByYear()
  566.     {
  567.         return $this->nbTournamentByYear;
  568.     }
  569.     
  570.     /**
  571.      * Set favoritePlayerM
  572.      *
  573.      * @param string $favoritePlayerM
  574.      *
  575.      * @return Player
  576.      */
  577.     public function setFavoritePlayerM($favoritePlayerM)
  578.     {
  579.         $this->favoritePlayerM $favoritePlayerM;
  580.         return $this;
  581.     }
  582.     /**
  583.      * Get favoritePlayerM
  584.      *
  585.      * @return string
  586.      */
  587.     public function getFavoritePlayerM()
  588.     {
  589.         return $this->favoritePlayerM;
  590.     }
  591.     
  592.     /**
  593.      * Set favoritePlayerF
  594.      *
  595.      * @param string $favoritePlayerF
  596.      *
  597.      * @return Player
  598.      */
  599.     public function setFavoritePlayerF($favoritePlayerF)
  600.     {
  601.         $this->favoritePlayerF $favoritePlayerF;
  602.         return $this;
  603.     }
  604.     /**
  605.      * Get favoritePlayerF
  606.      *
  607.      * @return string
  608.      */
  609.     public function getFavoritePlayerF()
  610.     {
  611.         return $this->favoritePlayerF;
  612.     }
  613.     
  614.     /**
  615.      * Set bestPerformance
  616.      *
  617.      * @param string $bestPerformance
  618.      *
  619.      * @return Player
  620.      */
  621.     public function setBestPerformance($bestPerformance)
  622.     {
  623.         $this->bestPerformance $bestPerformance;
  624.         return $this;
  625.     }
  626.     /**
  627.      * Get bestPerformance
  628.      *
  629.      * @return string
  630.      */
  631.     public function getBestPerformance()
  632.     {
  633.         return $this->bestPerformance;
  634.     }
  635.     
  636.     /**
  637.      * Set bestPerformanceDate
  638.      *
  639.      * @param \DateTime $bestPerformanceDate
  640.      *
  641.      * @return Player
  642.      */
  643.     public function setBestPerformanceDate($bestPerformanceDate)
  644.     {
  645.         $this->bestPerformanceDate $bestPerformanceDate;
  646.         return $this;
  647.     }
  648.     /**
  649.      * Get bestPerformanceDate
  650.      *
  651.      * @return \DateTime
  652.      */
  653.     public function getBestPerformanceDate()
  654.     {
  655.         return $this->bestPerformanceDate;
  656.     }
  657.     
  658.     /**
  659.      * Set bestMatchViewed
  660.      *
  661.      * @param string $bestMatchViewed
  662.      *
  663.      * @return Player
  664.      */
  665.     public function setBestMatchViewed($bestMatchViewed)
  666.     {
  667.         $this->bestMatchViewed $bestMatchViewed;
  668.         return $this;
  669.     }
  670.     /**
  671.      * Get bestMatchViewed
  672.      *
  673.      * @return string
  674.      */
  675.     public function getBestMatchViewed()
  676.     {
  677.         return $this->bestMatchViewed;
  678.     }
  679.     
  680.     /**
  681.      * Set club
  682.      *
  683.      * @param RankingSystem $club
  684.      *
  685.      * @return Player
  686.      */
  687.     public function setClub($club)
  688.     {
  689.         $this->club $club;
  690.         return $this;
  691.     }
  692.     /**
  693.      * Get club
  694.      *
  695.      * @return Club
  696.      */
  697.     public function getClub()
  698.     {
  699.         return $this->club;
  700.     }
  701.     
  702.     /**
  703.      * Set otherClub
  704.      *
  705.      * @param string $otherClub
  706.      *
  707.      * @return Player
  708.      */
  709.     public function setOtherClub($otherClub)
  710.     {
  711.         $this->otherClub $otherClub;
  712.         return $this;
  713.     }
  714.     /**
  715.      * Get otherClub
  716.      *
  717.      * @return string
  718.      */
  719.     public function getOtherClub()
  720.     {
  721.         return $this->otherClub;
  722.     }
  723.     
  724.     /**
  725.      * Add wish
  726.      *
  727.      * @param \App\Entity\Player\PlayerWish $wish
  728.      *
  729.      * @return Player
  730.      */
  731.     public function addWish(\App\Entity\Player\PlayerWish $wish)
  732.     {
  733.         
  734.         if (!$this->wishes->contains($wish)) {
  735.             $this->wishes[] = $wish;
  736.         }
  737.         return $this;
  738.     }
  739.     /**
  740.      * Remove wish
  741.      *
  742.      * @param \App\Entity\Player\PlayerWish $wish
  743.      */
  744.     public function removeWish(\App\Entity\Player\PlayerWish $wish)
  745.     {
  746.         if ($this->wishes->contains($wish)) {
  747.             $this->wishes->removeElement($wish);
  748.         }
  749.         return $this;
  750.     }
  751.     /**
  752.      * Get wishes
  753.      *
  754.      * @return \Doctrine\Common\Collections\Collection
  755.      */
  756.     public function getWishes()
  757.     {
  758.         return $this->wishes;
  759.     }
  760.     
  761.     /**
  762.      * Add availability
  763.      *
  764.      * @param \App\Entity\Player\PlayerAvailability $availability
  765.      *
  766.      * @return Player
  767.      */
  768.     public function addAvailability(\App\Entity\Player\PlayerAvailability $availability)
  769.     {
  770.         if (!$this->availabilities->contains($availability)) {
  771.             $this->availabilities[] = $availability;
  772.         }
  773.         return $this;
  774.     }
  775.     /**
  776.      * Remove availability
  777.      *
  778.      * @param \App\Entity\Player\PlayerAvailability $availability
  779.      */
  780.     public function removeAvailability(\App\Entity\Player\PlayerAvailability $availability)
  781.     {
  782.         if ($this->availabilities->contains($availability)) {
  783.             $this->availabilities->removeElement($availability);
  784.         }
  785.         
  786.         return $this;
  787.     }
  788.     /**
  789.      * Get availabilities
  790.      *
  791.      * @return \Doctrine\Common\Collections\Collection
  792.      */
  793.     public function getAvailabilities()
  794.     {
  795.         return $this->availabilities;
  796.     }
  797.     
  798.     
  799.     
  800.     /***********************
  801.      * OTHER FUNCTION
  802.      ***********************/
  803.      
  804.      public function updateFromJson($jsonObject){
  805.         if(isset($jsonObject->gimmick) &&  $jsonObject->gimmick != ""){
  806.             $this->setGimmick($jsonObject->gimmick);
  807.         }else{
  808.             $this->setGimmick(null);
  809.         }
  810.         
  811.         if(isset($jsonObject->birthdate) &&  $jsonObject->birthdate != ""){
  812.             $this->setBirthdate(new \Datetime($jsonObject->birthdate));
  813.         }
  814.         
  815.         if(isset($jsonObject->gender) &&  $jsonObject->gender != ""){
  816.             if($jsonObject->gender == 'MALE'){
  817.                 $this->setGender('M');
  818.             }else{
  819.                 $this->setGender('F');
  820.             }
  821.         }
  822.         
  823.         if(isset($jsonObject->bestRankingDate) &&  $jsonObject->bestRankingDate != ""){
  824.             $this->setBestRankingDate(new \Datetime($jsonObject->bestRankingDate));
  825.         }
  826.         
  827.         if(isset($jsonObject->hand) &&  $jsonObject->hand != ""){
  828.             $this->setHand($jsonObject->hand);
  829.         }
  830.         
  831.         if(isset($jsonObject->nbPlayByWeek)){
  832.             $this->setNbPlayByWeek($jsonObject->nbPlayByWeek);
  833.         }    
  834.         
  835.         if(isset($jsonObject->favoritePlayerM)){
  836.             $this->setFavoritePlayerM($jsonObject->favoritePlayerM);
  837.         }
  838.         
  839.         if(isset($jsonObject->favoritePlayerF)){
  840.             $this->setFavoritePlayerF($jsonObject->favoritePlayerF);
  841.         }
  842.         
  843.         if(isset($jsonObject->bestMatchViewed)){
  844.             $this->setBestMatchViewed($jsonObject->bestMatchViewed);
  845.         }
  846.         
  847.         if(isset($jsonObject->bestPerformance)){
  848.             $this->setBestPerformance($jsonObject->bestPerformance);
  849.         }
  850.         
  851.         if(isset($jsonObject->bestPerformanceDate) &&  $jsonObject->bestPerformanceDate != ""){
  852.             $this->setBestPerformanceDate(new \Datetime($jsonObject->bestPerformanceDate));
  853.         }
  854.     }
  855.     
  856.     public function getArrayForJson($userTools null$currentUser null){
  857.         $array = array();
  858.         $array['id'] = $this->getId();
  859.         $array['gender'] = ($this->getGender() == 'F') ? 'FEMALE' 'MALE';
  860.         $array['gimmick'] = $this->getGimmick();
  861.         if($this->getBirthdate())
  862.             $array['birthdate'] = $this->getBirthdate()->format("Y-m-d\TH:i:sP"); // 2013-12-19T00:00:00+01:00
  863.         if($this->getCurrentRanking()){
  864.             $array['currentRanking'] = $this->getCurrentRanking()->getArrayForJson();
  865.             if($userTools)
  866.                 $array['correspondingRanking'] = $userTools->getStringCorrespondingRanking($currentUser$this->getUser());
  867.         }
  868.         if($this->getBestRanking()){
  869.             $array['bestRanking'] = $this->getBestRanking()->getArrayForJson();
  870.             if($this->getBestRankingDate())
  871.                 $array['bestRankingDate'] = $this->getBestRankingDate()->format("Y-m-d\TH:i:sP");
  872.         }
  873.         $array['hand'] = $this->getHand();
  874.         if($this->getPlayerType()){
  875.             $array['playerType'] = $this->getPlayerType()->getArrayForJson();
  876.         }
  877.         if($this->getBrandRacket()){
  878.             $array['brandRacket'] = $this->getBrandRacket()->getArrayForJson();
  879.         }
  880.         if($this->getBrandShoe()){
  881.             $array['brandShoe'] = $this->getBrandShoe()->getArrayForJson();
  882.         }
  883.         $array['nbPlayByWeek'] = $this->getNbPlayByWeek();
  884.         if($this->getNbTournamentByYear()){
  885.             $array['nbTournamentByYear'] = $this->getNbTournamentByYear()->getArrayForJson();
  886.         }
  887.         $array['favoritePlayerM'] = $this->getFavoritePlayerM();
  888.         $array['favoritePlayerF'] = $this->getFavoritePlayerF();
  889.         $array['bestPerformance'] = $this->getBestPerformance();
  890.         if($this->getBestPerformanceDate())
  891.             $array['bestPerformanceDate'] = $this->getBestPerformanceDate()->format("Y-m-d\TH:i:sP");
  892.         $array['bestMatchViewed'] = $this->getBestMatchViewed();
  893.         
  894.         if(count($this->getWishes()) > 0){
  895.             $arrayWishes = array();
  896.             foreach($this->getWishes() as $wish){
  897.                 $arrayWishes[] = $wish->getArrayForJson();
  898.             }
  899.             $array['wishes'] = $arrayWishes;
  900.         }
  901.         
  902.         if(count($this->getAvailabilities()) > 0){
  903.             $arrayAvailabilities = array();
  904.             foreach($this->getAvailabilities() as $availability){
  905.                 $arrayAvailabilities[] = $availability->getArrayForJson();
  906.             }
  907.             $array['availabilities'] = $arrayAvailabilities;
  908.         }
  909.         
  910.         
  911.         return $array;
  912.         
  913.     }
  914.     
  915.     
  916. }