2019-10-25 14:59:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Entity;
|
|
|
|
|
2019-11-12 11:26:19 +01:00
|
|
|
use DateTimeInterface;
|
2019-10-25 14:59:20 +02:00
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
2019-11-06 14:54:04 +01:00
|
|
|
use JMS\Serializer\Annotation as Serializer;
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\VoteRepository")
|
|
|
|
*/
|
|
|
|
class Vote {
|
|
|
|
/**
|
2019-11-12 11:26:19 +01:00
|
|
|
* for a text kind of choice: could be "yes" "no" "maybe" and emptu.
|
|
|
|
* for a date kind, the choice linked is equivalent to the value selected
|
2019-11-27 20:55:59 +01:00
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
|
* @Serializer\Type("string")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Expose()
|
2019-10-25 14:59:20 +02:00
|
|
|
*/
|
2019-11-27 20:55:59 +01:00
|
|
|
public $value;
|
2019-10-25 14:59:20 +02:00
|
|
|
/**
|
2019-11-27 17:07:11 +01:00
|
|
|
* @ORM\Column(type="datetime" , options={"default"="CURRENT_TIMESTAMP"})
|
2019-11-06 14:54:04 +01:00
|
|
|
* @Serializer\Type("datetime")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Expose()
|
2019-10-25 14:59:20 +02:00
|
|
|
*/
|
2019-11-06 14:54:04 +01:00
|
|
|
public $creationDate;
|
2019-11-06 14:35:07 +01:00
|
|
|
/**
|
2019-11-28 11:51:25 +01:00
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Choice", inversedBy="votes", cascade={"persist"})
|
2019-11-06 14:35:07 +01:00
|
|
|
* @ORM\JoinColumn(nullable=false)
|
2019-11-06 14:54:04 +01:00
|
|
|
* @Serializer\Type("App\Entity\choice")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Expose()
|
2019-11-06 14:35:07 +01:00
|
|
|
*/
|
2019-11-06 14:54:04 +01:00
|
|
|
public $choice;
|
2019-11-12 11:26:19 +01:00
|
|
|
/**
|
|
|
|
* @ORM\Id()
|
|
|
|
* @ORM\GeneratedValue()
|
|
|
|
* @ORM\Column(type="integer")
|
|
|
|
* @Serializer\Type("integer")
|
2020-01-20 17:27:59 +01:00
|
|
|
* @Serializer\Expose()
|
2019-11-12 11:26:19 +01:00
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
/**
|
2019-11-28 11:51:25 +01:00
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Poll", inversedBy="votes", cascade={"persist"})
|
2019-11-12 11:26:19 +01:00
|
|
|
* @ORM\JoinColumn(nullable=false)
|
|
|
|
* @Serializer\Type("App\Entity\Poll")
|
|
|
|
*/
|
|
|
|
private $poll;
|
2019-11-27 11:26:21 +01:00
|
|
|
/**
|
2019-11-27 17:07:11 +01:00
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\StackOfVotes", inversedBy="votes", cascade={"persist"})
|
2019-11-27 11:26:21 +01:00
|
|
|
* @ORM\JoinColumn(nullable=false)
|
|
|
|
* @Serializer\Type("App\Entity\StackOfVotes")
|
|
|
|
*/
|
2019-11-28 11:51:25 +01:00
|
|
|
private $stacksOfVotes;
|
2019-10-25 14:59:20 +02:00
|
|
|
|
2019-11-27 10:57:06 +01:00
|
|
|
public function __construct() {
|
|
|
|
$this->setCreationDate( new \DateTime() );
|
|
|
|
}
|
|
|
|
|
2019-10-25 14:59:20 +02:00
|
|
|
public function getId(): ?int {
|
2019-11-06 14:54:04 +01:00
|
|
|
return $this->id;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function getPoll(): ?Poll {
|
2019-11-06 14:54:04 +01:00
|
|
|
return $this->poll;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
|
|
|
|
public function setPoll( ?Poll $poll ): self {
|
2019-11-06 14:54:04 +01:00
|
|
|
$this->poll = $poll;
|
2019-11-27 17:07:11 +01:00
|
|
|
if ( $poll ) {
|
|
|
|
$poll->addVote( $this );
|
|
|
|
}
|
2019-11-06 14:54:04 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getChoice(): ?Choice {
|
|
|
|
return $this->choice;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setChoice( ?Choice $choice ): self {
|
|
|
|
$this->choice = $choice;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-11-12 11:26:19 +01:00
|
|
|
|
|
|
|
public function getValue(): ?string {
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
2019-11-27 20:55:59 +01:00
|
|
|
public function setValue( ?string $value ): self {
|
2019-11-12 11:26:19 +01:00
|
|
|
$this->value = $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCreationDate(): ?DateTimeInterface {
|
|
|
|
return $this->creationDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCreationDate( DateTimeInterface $creationDate ): self {
|
|
|
|
$this->creationDate = $creationDate;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-11-27 11:26:21 +01:00
|
|
|
|
2019-11-28 11:51:25 +01:00
|
|
|
public function getStacksOfVotes(): ?StackOfVotes {
|
|
|
|
return $this->stacksOfVotes;
|
2019-11-27 11:26:21 +01:00
|
|
|
}
|
|
|
|
|
2019-11-28 11:51:25 +01:00
|
|
|
public function setStacksOfVotes( ?StackOfVotes $stacksOfVotes ): self {
|
|
|
|
$this->stacksOfVotes = $stacksOfVotes;
|
2019-11-27 11:26:21 +01:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-10-25 14:59:20 +02:00
|
|
|
}
|