src/Entity/TeamPlayer.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TeamPlayerRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Ignore;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=TeamPlayerRepository::class)
  11.  */
  12. class TeamPlayer
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      * @Groups({"atpmatch_result:list", "atpmatch_result:item"})
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="integer")
  23.      * @Groups({"atpmatch_result:list", "atpmatch_result:item"})
  24.      */
  25.     private $orderInTeam;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=MatchTeam::class, inversedBy="teamPlayer", cascade={"persist", "remove"})
  28.      * @Ignore
  29.      */
  30.     private $matchTeam;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Player::class, inversedBy="teamPlayers")
  33.      * @Groups({"atpmatch_result:list", "atpmatch_result:item"})
  34.      */
  35.     private $player;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity=Player::class, inversedBy="teamPlayerPartner")
  38.      * @Groups({"atpmatch_result:list", "atpmatch_result:item"})
  39.      */
  40.     private $partner;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=ATPMatchResult::class, mappedBy="playerTeam1")
  43.      * @Ignore()
  44.      */
  45.     private $aTPMatchResults;
  46.     /**
  47.      * @ORM\OneToMany(targetEntity=ATPMatchResult::class, mappedBy="playerTeam2")
  48.      * @Ignore()
  49.      */
  50.     private $atPMatchResults2;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=Set::class, mappedBy="teamPlayer",cascade={"persist"})
  53.      * @Groups({"atpmatch_result:list", "atpmatch_result:item","round:list"})
  54.      */
  55.     private $sets;
  56.     public function __construct()
  57.     {
  58.         $this->aTPMatchResults = new ArrayCollection();
  59.         $this->atPMatchResults2 = new ArrayCollection();
  60.         $this->sets = new ArrayCollection();
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getOrderInTeam(): ?int
  67.     {
  68.         return $this->orderInTeam;
  69.     }
  70.     public function setOrderInTeam(int $orderInTeam): self
  71.     {
  72.         $this->orderInTeam $orderInTeam;
  73.         return $this;
  74.     }
  75.     public function getMatchTeam(): ?MatchTeam
  76.     {
  77.         return $this->matchTeam;
  78.     }
  79.     public function setMatchTeam(?MatchTeam $matchTeam): self
  80.     {
  81.         $this->matchTeam $matchTeam;
  82.         return $this;
  83.     }
  84.     public function getPlayer(): ?Player
  85.     {
  86.         return $this->player;
  87.     }
  88.     public function setPlayer(?Player $player): self
  89.     {
  90.         $this->player $player;
  91.         return $this;
  92.     }
  93.     /**
  94.      * @return Collection|ATPMatchResult[]
  95.      */
  96.     public function getATPMatchResults(): Collection
  97.     {
  98.         return $this->aTPMatchResults;
  99.     }
  100.     public function addATPMatchResult(ATPMatchResult $aTPMatchResult): self
  101.     {
  102.         if (!$this->aTPMatchResults->contains($aTPMatchResult)) {
  103.             $this->aTPMatchResults[] = $aTPMatchResult;
  104.             $aTPMatchResult->setPlayerTeam1($this);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeATPMatchResult(ATPMatchResult $aTPMatchResult): self
  109.     {
  110.         if ($this->aTPMatchResults->removeElement($aTPMatchResult)) {
  111.             // set the owning side to null (unless already changed)
  112.             if ($aTPMatchResult->getPlayerTeam1() === $this) {
  113.                 $aTPMatchResult->setPlayerTeam1(null);
  114.             }
  115.         }
  116.         return $this;
  117.     }
  118.     /**
  119.      * @return Collection|ATPMatchResult[]
  120.      */
  121.     public function getAtPMatchResults2(): Collection
  122.     {
  123.         return $this->atPMatchResults2;
  124.     }
  125.     public function addAtPMatchResults2(ATPMatchResult $atPMatchResults2): self
  126.     {
  127.         if (!$this->atPMatchResults2->contains($atPMatchResults2)) {
  128.             $this->atPMatchResults2[] = $atPMatchResults2;
  129.             $atPMatchResults2->setPlayerTeam2($this);
  130.         }
  131.         return $this;
  132.     }
  133.     public function removeAtPMatchResults2(ATPMatchResult $atPMatchResults2): self
  134.     {
  135.         if ($this->atPMatchResults2->removeElement($atPMatchResults2)) {
  136.             // set the owning side to null (unless already changed)
  137.             if ($atPMatchResults2->getPlayerTeam2() === $this) {
  138.                 $atPMatchResults2->setPlayerTeam2(null);
  139.             }
  140.         }
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Collection|Set[]
  145.      */
  146.     public function getSets(): Collection
  147.     {
  148.         return $this->sets;
  149.     }
  150.     public function addSet(Set $set): self
  151.     {
  152.         if (!$this->sets->contains($set)) {
  153.             $this->sets[] = $set;
  154.             $set->setTeamPlayer($this);
  155.         }
  156.         return $this;
  157.     }
  158.     public function removeSet(Set $set): self
  159.     {
  160.         if ($this->sets->removeElement($set)) {
  161.             // set the owning side to null (unless already changed)
  162.             if ($set->getTeamPlayer() === $this) {
  163.                 $set->setTeamPlayer(null);
  164.             }
  165.         }
  166.         return $this;
  167.     }
  168.     public function removeSets(): self
  169.     {
  170.         foreach ($this->getSets() as $set){
  171.             if ($this->sets->removeElement($set)) {
  172.                 // set the owning side to null (unless already changed)
  173.                 if ($set->getTeamPlayer() === $this) {
  174.                     $set->setTeamPlayer(null);
  175.                 }
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.     public function getPartner(): ?Player
  181.     {
  182.         return $this->partner;
  183.     }
  184.     public function setPartner(?Player $partner): self
  185.     {
  186.         $this->partner $partner;
  187.         return $this;
  188.     }
  189. }