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-05 17:31:07 +01:00
|
|
|
use JMS\Serializer\Annotation as Serializer;
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\PollRepository")
|
2019-11-05 17:31:07 +01:00
|
|
|
* @Serializer\ExclusionPolicy("ALL")
|
2019-10-25 14:59:20 +02:00
|
|
|
*/
|
|
|
|
class Poll {
|
|
|
|
/**
|
|
|
|
* @ORM\Id()
|
|
|
|
* @ORM\GeneratedValue()
|
|
|
|
* @ORM\Column(type="integer")
|
2019-11-05 17:31:07 +01:00
|
|
|
* @Serializer\Expose
|
2019-10-25 14:59:20 +02:00
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="string", length=255)
|
2019-11-05 17:31:07 +01:00
|
|
|
* @Serializer\Expose
|
2019-10-25 14:59:20 +02:00
|
|
|
*/
|
|
|
|
private $title;
|
2019-11-05 17:22:30 +01:00
|
|
|
/**
|
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
2019-11-05 17:31:07 +01:00
|
|
|
* @Serializer\Expose
|
2019-11-05 17:22:30 +01:00
|
|
|
*/
|
|
|
|
private $customUrl;
|
|
|
|
|
|
|
|
/**
|
2019-11-05 17:31:07 +01:00
|
|
|
* vote restricted by a password in md5 format
|
2019-11-05 17:22:30 +01:00
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
|
*/
|
|
|
|
private $password;
|
2019-11-05 17:31:07 +01:00
|
|
|
|
2019-11-05 17:22:30 +01:00
|
|
|
/**
|
|
|
|
* @ORM\Column(type="string", length=1000)
|
2019-11-05 17:31:07 +01:00
|
|
|
* @Serializer\Expose
|
2019-11-05 17:22:30 +01:00
|
|
|
*/
|
|
|
|
private $description;
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="datetime")
|
2019-11-05 17:31:07 +01:00
|
|
|
* @Serializer\Expose
|
2019-10-25 14:59:20 +02:00
|
|
|
*/
|
|
|
|
private $creationDate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="datetime")
|
|
|
|
*/
|
|
|
|
private $expiracyDate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Owner", inversedBy="polls")
|
|
|
|
* @ORM\JoinColumn(nullable=false)
|
|
|
|
*/
|
|
|
|
private $owner;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* used to allow administration
|
|
|
|
* @ORM\Column(type="string", length=255)
|
|
|
|
*/
|
|
|
|
private $adminKey;
|
2019-11-05 17:22:30 +01:00
|
|
|
/**
|
|
|
|
* kind of poll, text or date
|
|
|
|
* @ORM\Column(type="string", length=255)
|
|
|
|
*/
|
|
|
|
private $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)
|
|
|
|
*/
|
|
|
|
private $modificationPolicy;
|
|
|
|
/**
|
|
|
|
* send a mail on a new comment
|
|
|
|
* @ORM\Column(type="boolean", nullable=true)
|
|
|
|
*/
|
|
|
|
private $mailOnComment;
|
|
|
|
/**
|
|
|
|
* send a mail on a new vote
|
|
|
|
* @ORM\Column(type="boolean", nullable=true)
|
|
|
|
*/
|
|
|
|
private $mailOnVote;
|
|
|
|
/**
|
|
|
|
* hide publicly results
|
|
|
|
* @ORM\Column(type="boolean", nullable=true)
|
|
|
|
*/
|
|
|
|
private $hideResults;
|
|
|
|
/**
|
|
|
|
* show publicly results even if there is a password to access the vote
|
|
|
|
* @ORM\Column(type="boolean", nullable=true)
|
|
|
|
*/
|
|
|
|
private $showResultEvenIfPasswords;
|
2019-10-25 14:59:20 +02:00
|
|
|
|
2019-11-05 17:22:30 +01:00
|
|
|
/**
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="poll", orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
private $votes;
|
2019-10-25 14:59:20 +02:00
|
|
|
|
2019-11-05 17:22:30 +01:00
|
|
|
public function __construct() {
|
|
|
|
$this->votes = new ArrayCollection();
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function getId(): ?int {
|
2019-11-05 17:22:30 +01:00
|
|
|
return $this->id;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function getTitle(): ?string {
|
2019-11-05 17:22:30 +01:00
|
|
|
return $this->title;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function setTitle( string $title ): self {
|
2019-11-05 17:22:30 +01:00
|
|
|
$this->title = $title;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function getCreationDate(): ?\DateTimeInterface {
|
2019-11-05 17:22:30 +01:00
|
|
|
return $this->creationDate;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function setCreationDate( \DateTimeInterface $creationDate ): self {
|
2019-11-05 17:22:30 +01:00
|
|
|
$this->creationDate = $creationDate;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function getExpiracyDate(): ?\DateTimeInterface {
|
2019-11-05 17:22:30 +01:00
|
|
|
return $this->expiracyDate;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function setExpiracyDate( \DateTimeInterface $expiracyDate ): self {
|
2019-11-05 17:22:30 +01:00
|
|
|
$this->expiracyDate = $expiracyDate;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function getOwner(): ?Owner {
|
2019-11-05 17:22:30 +01:00
|
|
|
return $this->owner;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function setOwner( ?Owner $owner ): self {
|
2019-11-05 17:22:30 +01:00
|
|
|
$this->owner = $owner;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Collection|Vote[]
|
|
|
|
*/
|
|
|
|
public function getVotes(): Collection {
|
|
|
|
return $this->votes;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
}
|