date-poll-api/src/Entity/Owner.php

168 lines
4.3 KiB
PHP
Raw Normal View History

2019-10-25 14:59:20 +02:00
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
2019-11-06 12:27:46 +01:00
use JMS\Serializer\Annotation as Serializer;
2019-10-25 14:59:20 +02:00
/**
* @ORM\Entity(repositoryClass="App\Repository\OwnerRepository")
*/
2019-11-06 12:27:46 +01:00
class Owner {
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
* @Serializer\Expose()
2019-11-06 12:27:46 +01:00
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
* @Serializer\Expose()
2019-11-06 12:27:46 +01:00
*/
public $pseudo;
2019-11-06 12:27:46 +01:00
/**
* @ORM\OneToMany(targetEntity="App\Entity\Poll", mappedBy="owner",cascade={"persist"})
* @Serializer\Type("App\Entity\Poll")
*/
private $polls;
2019-11-06 14:54:04 +01:00
/**
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="owner")
*/
private $comments;
2019-11-11 10:44:19 +01:00
/**
* @ORM\OneToMany(targetEntity="App\Entity\StackOfVotes", mappedBy="owner")
*/
private $stackOfVotes;
2019-11-06 12:27:46 +01:00
public function __construct() {
2019-11-11 10:44:19 +01:00
$this->polls = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->stackOfVotes = new ArrayCollection();
}
2019-11-06 12:27:46 +01:00
public function getId(): ?int {
2019-11-11 10:44:19 +01:00
return $this->id;
}
2019-11-06 12:27:46 +01:00
public function getEmail(): ?string {
2019-11-11 10:44:19 +01:00
return $this->email;
}
2019-11-06 12:27:46 +01:00
public function setEmail( string $email ): self {
2019-11-11 10:44:19 +01:00
$this->email = $email;
return $this;
}
2019-11-06 12:27:46 +01:00
public function getPseudo(): ?string {
2019-11-11 10:44:19 +01:00
return $this->pseudo;
}
2019-11-06 12:27:46 +01:00
public function setPseudo( string $pseudo ): self {
2019-11-11 10:44:19 +01:00
$this->pseudo = $pseudo;
return $this;
}
2019-11-06 12:27:46 +01:00
/**
* @return Collection|Poll[]
*/
public function getPolls(): Collection {
2019-11-11 10:44:19 +01:00
return $this->polls;
}
2019-11-06 12:27:46 +01:00
public function addPoll( Poll $poll ): self {
2019-11-11 10:44:19 +01:00
if ( ! $this->polls->contains( $poll ) ) {
$this->polls[] = $poll;
$poll->setOwner( $this );
}
return $this;
}
2019-11-06 12:27:46 +01:00
public function removePoll( Poll $poll ): self {
2019-11-11 10:44:19 +01:00
if ( $this->polls->contains( $poll ) ) {
$this->polls->removeElement( $poll );
// set the owning side to null (unless already changed)
if ( $poll->getOwner() === $this ) {
$poll->setOwner( null );
}
}
return $this;
}
2019-11-06 14:54:04 +01:00
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection {
2019-11-11 10:44:19 +01:00
return $this->comments;
}
2019-11-06 14:54:04 +01:00
public function addText( Comment $text ): self {
2019-11-11 10:44:19 +01:00
if ( ! $this->comments->contains( $text ) ) {
$this->comments[] = $text;
$text->setOwner( $this );
}
return $this;
}
2019-11-06 14:54:04 +01:00
public function removeText( Comment $text ): self {
2019-11-11 10:44:19 +01:00
if ( $this->comments->contains( $text ) ) {
$this->comments->removeElement( $text );
// set the owning side to null (unless already changed)
if ( $text->getOwner() === $this ) {
$text->setOwner( null );
}
}
return $this;
}
/**
* @return Collection|StackOfVotes[]
*/
public function getStackOfVotes(): Collection
{
return $this->stackOfVotes;
}
public function addStackOfVote(StackOfVotes $stackOfVote): self
{
if (!$this->stackOfVotes->contains($stackOfVote)) {
$this->stackOfVotes[] = $stackOfVote;
$stackOfVote->setOwner($this);
}
return $this;
}
public function removeStackOfVote(StackOfVotes $stackOfVote): self
{
if ($this->stackOfVotes->contains($stackOfVote)) {
$this->stackOfVotes->removeElement($stackOfVote);
// set the owning side to null (unless already changed)
if ($stackOfVote->getOwner() === $this) {
$stackOfVote->setOwner(null);
}
}
return $this;
}
2019-10-25 14:59:20 +02:00
}