1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00
date-poll-api/src/Entity/Poll.php
2019-11-20 11:24:54 +01:00

411 lines
10 KiB
PHP

<?php
namespace App\Entity;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
/**
* @ORM\Entity(repositoryClass="App\Repository\PollRepository")
*/
class Poll {
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Serializer\Expose()
* @Serializer\Type("integer")
*/
public $id;
/**
* @ORM\Column(type="string", length=255)
* @Serializer\Expose()
* @Serializer\Type("string")
*/
public $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Serializer\Expose()
* @Serializer\Type("string")
*/
public $customUrl;
/**
* @ORM\Column(type="string", length=1000)
* @Serializer\Expose()
* @Serializer\Type("string")
*/
public $description;
/**
* @ORM\Column(type="datetime")
* @Serializer\Expose()
*/
public $creationDate;
/**
* @ORM\Column(type="datetime")
*/
public $expiracyDate;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Owner", inversedBy="polls",cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
* @Serializer\Type("App\Entity\Owner")
*/
public $owner;
/**
* kind of poll, text or date
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
* @Serializer\Expose()
*/
public $kind;
/**
* kind of way the people can modify the poll
* everybody - can modify votes
* self - one can only modify its own vote
* nobody - no one can modify the votes (excepted admin), pray to have it right at first
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
*/
public $modificationPolicy;
/**
* send a mail on a new comment
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Type("boolean")
*/
public $mailOnComment;
/**
* send a mail on a new vote
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Type("boolean")
*/
public $mailOnVote;
/**
* hide publicly results
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Type("boolean")
*/
public $hideResults;
/**
* show publicly results even if there is a password to access the vote
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Type("boolean")
*/
public $showResultEvenIfPasswords;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="poll", orphanRemoval=true,cascade={"persist", "remove"})
* @Serializer\Type("App\Entity\Vote")
*/
public $votes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\StackOfVotes", mappedBy="poll", orphanRemoval=true,cascade={"persist", "remove"})
* @Serializer\Type("App\Entity\StackOfVotes")
*/
public $stackOfVotes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Choice", mappedBy="poll", orphanRemoval=true,cascade={"persist", "remove"})
* @Serializer\Type("App\Entity\Choice")
*/
public $choices;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="poll", orphanRemoval=true,cascade={"persist", "remove"})
* @Serializer\Type("App\Entity\Comment")
*/
public $comments;
/**
* vote restricted by a password in md5 format
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $password;
/**
* used to allow administration
* @ORM\Column(type="string", length=255)
* @Serializer\Type("string")
*/
private $adminKey;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\StackOfVotes", inversedBy="votes")
*/
private $stacksOfVotes;
public function __construct() {
$this->votes = new ArrayCollection();
$this->choices = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->stackOfVotes = new ArrayCollection();
}
public function getId(): ?int {
return $this->id;
}
public function getTitle(): ?string {
return $this->title;
}
public function setTitle( string $title ): self {
$this->title = $title;
return $this;
}
public function getCreationDate(): ?DateTimeInterface {
return $this->creationDate;
}
public function setCreationDate( DateTimeInterface $creationDate ): self {
$this->creationDate = $creationDate;
return $this;
}
public function setExpiracyDate( DateTimeInterface $expiracyDate ): self {
$this->expiracyDate = $expiracyDate;
return $this;
}
public function getOwner(): ?Owner {
return $this->owner;
}
public function setOwner( ?Owner $owner ): self {
$this->owner = $owner;
return $this;
}
/**
* @return Collection|Vote[]
*/
public function getVotes(): Collection {
return $this->votes;
}
public function getAdminKey(): ?string {
return $this->adminKey;
}
public function setAdminKey( string $adminKey ): self {
$this->adminKey = $adminKey;
return $this;
}
public function getDescription(): ?string {
return $this->description;
}
public function setDescription( string $description ): self {
$this->description = $description;
return $this;
}
public function getKind(): ?string {
return $this->kind;
}
public function setKind( string $kind ): self {
$this->kind = $kind;
return $this;
}
public function getCustomUrl(): ?string {
return $this->customUrl;
}
public function setCustomUrl( string $customUrl ): self {
$this->customUrl = $customUrl;
return $this;
}
public function getPassword(): ?string {
return $this->password;
}
public function setPassword( string $password ): self {
$this->password = $password;
return $this;
}
public function getModificationPolicy(): ?string {
return $this->modificationPolicy;
}
public function setModificationPolicy( string $modificationPolicy ): self {
$this->modificationPolicy = $modificationPolicy;
return $this;
}
public function getMailOnComment(): ?bool {
return $this->mailOnComment;
}
public function setMailOnComment( bool $mailOnComment ): self {
$this->mailOnComment = $mailOnComment;
return $this;
}
public function getMailOnVote(): ?bool {
return $this->mailOnVote;
}
public function setMailOnVote( bool $mailOnVote ): self {
$this->mailOnVote = $mailOnVote;
return $this;
}
public function getHideResults(): ?bool {
return $this->hideResults;
}
public function setHideResults( bool $hideResults ): self {
$this->hideResults = $hideResults;
return $this;
}
public function getShowResultEvenIfPasswords(): ?bool {
return $this->showResultEvenIfPasswords;
}
public function setShowResultEvenIfPasswords( bool $showResultEvenIfPasswords ): self {
$this->showResultEvenIfPasswords = $showResultEvenIfPasswords;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection {
return $this->comments;
}
public function addComment( Comment $comment ): self {
if ( ! $this->comments->contains( $comment ) ) {
$this->comments[] = $comment;
$comment->setPoll( $this );
}
return $this;
}
public function removeComment( Comment $comment ): self {
if ( $this->comments->contains( $comment ) ) {
$this->comments->removeElement( $comment );
// set the owning side to null (unless already changed)
if ( $comment->getPoll() === $this ) {
$comment->setPoll( null );
}
}
return $this;
}
public function getStacksOfVotes(): ?StackOfVotes {
return $this->stacksOfVotes;
}
public function setStacksOfVotes( ?StackOfVotes $stacksOfVotes ): self {
$this->stacksOfVotes = $stacksOfVotes;
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->setPoll( $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->getPoll() === $this ) {
$stackOfVote->setPoll( null );
}
}
return $this;
}
public function getExpiracyDate(): ?\DateTimeInterface {
return $this->expiracyDate;
}
public function addVote( Vote $vote ): self {
if ( ! $this->votes->contains( $vote ) ) {
$this->votes[] = $vote;
$vote->setPoll( $this );
}
return $this;
}
public function removeVote( Vote $vote ): self {
if ( $this->votes->contains( $vote ) ) {
$this->votes->removeElement( $vote );
// set the owning side to null (unless already changed)
if ( $vote->getPoll() === $this ) {
$vote->setPoll( null );
}
}
return $this;
}
/**
* @return Collection|Choice[]
*/
public function getChoices(): Collection
{
return $this->choices;
}
public function addChoice(Choice $choice): self
{
if (!$this->choices->contains($choice)) {
$this->choices[] = $choice;
$choice->setPoll($this);
}
return $this;
}
public function removeChoice(Choice $choice): self
{
if ($this->choices->contains($choice)) {
$this->choices->removeElement($choice);
// set the owning side to null (unless already changed)
if ($choice->getPoll() === $this) {
$choice->setPoll(null);
}
}
return $this;
}
}