mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
⚡ update modeling of entities
This commit is contained in:
parent
b7d1a51e2a
commit
324f3e7f32
@ -2,12 +2,14 @@
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* one poll choice, could be a text or a date
|
||||
* @ORM\Entity(repositoryClass="App\Repository\ChoiceRepository")
|
||||
*/
|
||||
class Choice {
|
||||
@ -36,94 +38,132 @@ class Choice {
|
||||
*/
|
||||
private $poll;
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Choice", mappedBy="choice")
|
||||
* @Serializer\Type("App\Entity\Choice")
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\StackOfVotes", mappedBy="choice")
|
||||
* @Serializer\Type("App\Entity\StackOfVotes")
|
||||
*/
|
||||
private $votes;
|
||||
private $stackOfVotes;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="choice")
|
||||
* @Serializer\Type("App\Entity\Vote")
|
||||
*/
|
||||
private $vote;
|
||||
|
||||
public function __construct() {
|
||||
$this->poll = new ArrayCollection();
|
||||
$this->votes = new ArrayCollection();
|
||||
}
|
||||
$this->poll = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
$this->vote = new ArrayCollection();
|
||||
}
|
||||
|
||||
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string {
|
||||
return $this->name;
|
||||
}
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName( string $name ): self {
|
||||
$this->name = $name;
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function getDateTime(): ?DateTimeInterface {
|
||||
return $this->dateTime;
|
||||
}
|
||||
|
||||
public function getDateTime(): ?\DateTimeInterface {
|
||||
return $this->dateTime;
|
||||
}
|
||||
|
||||
public function setDateTime( ?\DateTimeInterface $dateTime ): self {
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function setDateTime( ?DateTimeInterface $dateTime ): self {
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Poll[]
|
||||
*/
|
||||
public function getPoll(): Collection {
|
||||
return $this->poll;
|
||||
}
|
||||
return $this->poll;
|
||||
}
|
||||
|
||||
public function addPoll( Poll $poll ): self {
|
||||
if ( ! $this->poll->contains( $poll ) ) {
|
||||
$this->poll[] = $poll;
|
||||
$poll->setChoices( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
if ( ! $this->poll->contains( $poll ) ) {
|
||||
$this->poll[] = $poll;
|
||||
$poll->setChoices( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePoll( Poll $poll ): self {
|
||||
if ( $this->poll->contains( $poll ) ) {
|
||||
$this->poll->removeElement( $poll );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $poll->getChoices() === $this ) {
|
||||
$poll->setChoices( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
if ( $this->poll->contains( $poll ) ) {
|
||||
$this->poll->removeElement( $poll );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $poll->getChoices() === $this ) {
|
||||
$poll->setChoices( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Choice[]
|
||||
*/
|
||||
public function getVotes(): Collection {
|
||||
return $this->votes;
|
||||
}
|
||||
public function getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function addVote( Choice $vote ): self {
|
||||
if ( ! $this->votes->contains( $vote ) ) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setChoice( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
if ( ! $this->stackOfVotes->contains( $vote ) ) {
|
||||
$this->stackOfVotes[] = $vote;
|
||||
$vote->setChoice( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeVote( Choice $vote ): self {
|
||||
if ( $this->votes->contains( $vote ) ) {
|
||||
$this->votes->removeElement( $vote );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $vote->getChoice() === $this ) {
|
||||
$vote->setChoice( null );
|
||||
}
|
||||
}
|
||||
if ( $this->stackOfVotes->contains( $vote ) ) {
|
||||
$this->stackOfVotes->removeElement( $vote );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $vote->getChoice() === $this ) {
|
||||
$vote->setChoice( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function addStackOfVote(StackOfVotes $stackOfVote): self
|
||||
{
|
||||
if (!$this->stackOfVotes->contains($stackOfVote)) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setChoice($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->getChoice() === $this) {
|
||||
$stackOfVote->setChoice(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Vote[]
|
||||
*/
|
||||
public function getVote(): Collection
|
||||
{
|
||||
return $this->vote;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
@ -59,11 +60,11 @@ class Comment {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): ?\DateTimeInterface {
|
||||
public function getCreatedAt(): ?DateTimeInterface {
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function setCreatedAt( \DateTimeInterface $createdAt ): self {
|
||||
public function setCreatedAt( DateTimeInterface $createdAt ): self {
|
||||
$this->createdAt = $createdAt;
|
||||
|
||||
return $this;
|
||||
|
@ -11,27 +11,24 @@ use JMS\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity(repositoryClass="App\Repository\OwnerRepository")
|
||||
*/
|
||||
class Owner {
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Serializer\Type("string")
|
||||
* @Serializer\Expose()
|
||||
*/
|
||||
public $pseudo;
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Serializer\Type("string")
|
||||
* @Serializer\Expose()
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Serializer\Type("string")
|
||||
* @Serializer\Expose()
|
||||
*/
|
||||
public $pseudo;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Poll", mappedBy="owner",cascade={"persist"})
|
||||
* @Serializer\Type("App\Entity\Poll")
|
||||
@ -39,129 +36,163 @@ class Owner {
|
||||
private $polls;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="owner")
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="owner", cascade={"persist","remove"})
|
||||
*/
|
||||
private $comments;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\StackOfVotes", mappedBy="owner")
|
||||
*/
|
||||
private $stackOfVotes;
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\StackOfVotes", mappedBy="owner", cascade={"persist","remove"})
|
||||
*/
|
||||
private $stackOfVotes;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $modifierToken;
|
||||
|
||||
|
||||
public function __construct() {
|
||||
$this->polls = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
}
|
||||
$this->polls = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string {
|
||||
return $this->email;
|
||||
}
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail( string $email ): self {
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPseudo(): ?string {
|
||||
return $this->pseudo;
|
||||
}
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
public function setPseudo( string $pseudo ): self {
|
||||
$this->pseudo = $pseudo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->pseudo = $pseudo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Poll[]
|
||||
*/
|
||||
public function getPolls(): Collection {
|
||||
return $this->polls;
|
||||
}
|
||||
return $this->polls;
|
||||
}
|
||||
|
||||
public function addPoll( Poll $poll ): self {
|
||||
if ( ! $this->polls->contains( $poll ) ) {
|
||||
$this->polls[] = $poll;
|
||||
$poll->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
if ( ! $this->polls->contains( $poll ) ) {
|
||||
$this->polls[] = $poll;
|
||||
$poll->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePoll( Poll $poll ): self {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Comment[]
|
||||
*/
|
||||
public function getComments(): Collection {
|
||||
return $this->comments;
|
||||
}
|
||||
return $this->comments;
|
||||
}
|
||||
|
||||
public function addText( Comment $text ): self {
|
||||
if ( ! $this->comments->contains( $text ) ) {
|
||||
$this->comments[] = $text;
|
||||
$text->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
if ( ! $this->comments->contains( $text ) ) {
|
||||
$this->comments[] = $text;
|
||||
$text->setOwner( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeText( Comment $text ): self {
|
||||
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;
|
||||
}
|
||||
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 Collection|StackOfVotes[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection
|
||||
{
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addStackOfVote(StackOfVotes $stackOfVote): self
|
||||
{
|
||||
if (!$this->stackOfVotes->contains($stackOfVote)) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setOwner($this);
|
||||
}
|
||||
/**
|
||||
* @return Collection|StackOfVotes[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function addStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setOwner( $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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getModifierToken(): ?string {
|
||||
return $this->modifierToken;
|
||||
}
|
||||
|
||||
public function setModifierToken( string $modifierToken ): self {
|
||||
$this->modifierToken = $modifierToken;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addComment( Comment $comment ): self {
|
||||
if ( ! $this->comments->contains( $comment ) ) {
|
||||
$this->comments[] = $comment;
|
||||
$comment->setOwner( $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->getOwner() === $this ) {
|
||||
$comment->setOwner( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@ -32,44 +33,27 @@ class Poll {
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $customUrl;
|
||||
|
||||
/**
|
||||
* vote restricted by a password in md5 format
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* used to allow administration
|
||||
* @ORM\Column(type="string", length=255)
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
private $adminKey;
|
||||
/**
|
||||
* kind of poll, text or date
|
||||
* @ORM\Column(type="string", length=255)
|
||||
@ -110,271 +94,314 @@ class Poll {
|
||||
* @Serializer\Type("boolean")
|
||||
*/
|
||||
public $showResultEvenIfPasswords;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="poll", orphanRemoval=true,cascade={"persist"})
|
||||
* @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\Choice", mappedBy="poll", orphanRemoval=true,cascade={"persist"})
|
||||
* @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")
|
||||
* @Serializer\Type("App\Entity\Comment")
|
||||
*/
|
||||
public $comments;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\StackOfVotes", inversedBy="votes")
|
||||
*/
|
||||
private $stacksOfVotes;
|
||||
/**
|
||||
* 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->votes = new ArrayCollection();
|
||||
$this->choices = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string {
|
||||
return $this->title;
|
||||
}
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle( string $title ): self {
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreationDate(): ?\DateTimeInterface {
|
||||
return $this->creationDate;
|
||||
}
|
||||
public function getCreationDate(): ?DateTimeInterface {
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
public function setCreationDate( \DateTimeInterface $creationDate ): self {
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function setCreationDate( DateTimeInterface $creationDate ): self {
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExpiracyDate(): ?\DateTimeInterface {
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
public function getExpiracyDate(): ?DateTimeInterface {
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
|
||||
public function setExpiracyDate( \DateTimeInterface $expiracyDate ): self {
|
||||
$this->expiracyDate = $expiracyDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function setExpiracyDate( DateTimeInterface $expiracyDate ): self {
|
||||
$this->expiracyDate = $expiracyDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOwner(): ?Owner {
|
||||
return $this->owner;
|
||||
}
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function setOwner( ?Owner $owner ): self {
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Vote[]
|
||||
*/
|
||||
public function getVotes(): Collection {
|
||||
return $this->votes;
|
||||
}
|
||||
return $this->votes;
|
||||
}
|
||||
|
||||
public function addVote( Vote $vote ): self {
|
||||
if ( ! $this->votes->contains( $vote ) ) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setPoll( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
return $this->adminKey;
|
||||
}
|
||||
|
||||
public function setAdminKey( string $adminKey ): self {
|
||||
$this->adminKey = $adminKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->adminKey = $adminKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string {
|
||||
return $this->description;
|
||||
}
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription( string $description ): self {
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKind(): ?string {
|
||||
return $this->kind;
|
||||
}
|
||||
return $this->kind;
|
||||
}
|
||||
|
||||
public function setKind( string $kind ): self {
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCustomUrl(): ?string {
|
||||
return $this->customUrl;
|
||||
}
|
||||
return $this->customUrl;
|
||||
}
|
||||
|
||||
public function setCustomUrl( string $customUrl ): self {
|
||||
$this->customUrl = $customUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->customUrl = $customUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword(): ?string {
|
||||
return $this->password;
|
||||
}
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword( string $password ): self {
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getModificationPolicy(): ?string {
|
||||
return $this->modificationPolicy;
|
||||
}
|
||||
return $this->modificationPolicy;
|
||||
}
|
||||
|
||||
public function setModificationPolicy( string $modificationPolicy ): self {
|
||||
$this->modificationPolicy = $modificationPolicy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->modificationPolicy = $modificationPolicy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMailOnComment(): ?bool {
|
||||
return $this->mailOnComment;
|
||||
}
|
||||
return $this->mailOnComment;
|
||||
}
|
||||
|
||||
public function setMailOnComment( bool $mailOnComment ): self {
|
||||
$this->mailOnComment = $mailOnComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->mailOnComment = $mailOnComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMailOnVote(): ?bool {
|
||||
return $this->mailOnVote;
|
||||
}
|
||||
return $this->mailOnVote;
|
||||
}
|
||||
|
||||
public function setMailOnVote( bool $mailOnVote ): self {
|
||||
$this->mailOnVote = $mailOnVote;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->mailOnVote = $mailOnVote;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHideResults(): ?bool {
|
||||
return $this->hideResults;
|
||||
}
|
||||
return $this->hideResults;
|
||||
}
|
||||
|
||||
public function setHideResults( bool $hideResults ): self {
|
||||
$this->hideResults = $hideResults;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->hideResults = $hideResults;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowResultEvenIfPasswords(): ?bool {
|
||||
return $this->showResultEvenIfPasswords;
|
||||
}
|
||||
return $this->showResultEvenIfPasswords;
|
||||
}
|
||||
|
||||
public function setShowResultEvenIfPasswords( bool $showResultEvenIfPasswords ): self {
|
||||
$this->showResultEvenIfPasswords = $showResultEvenIfPasswords;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->showResultEvenIfPasswords = $showResultEvenIfPasswords;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Choice[]
|
||||
*/
|
||||
public function getChoices(): Collection {
|
||||
return $this->choices;
|
||||
}
|
||||
return $this->choices;
|
||||
}
|
||||
|
||||
public function addChoice( Choice $choice ): self {
|
||||
if ( ! $this->choices->contains( $choice ) ) {
|
||||
$this->choices[] = $choice;
|
||||
$choice->setPoll( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Comment[]
|
||||
*/
|
||||
public function getComments(): Collection {
|
||||
return $this->comments;
|
||||
}
|
||||
return $this->comments;
|
||||
}
|
||||
|
||||
public function addComment( Comment $comment ): self {
|
||||
if ( ! $this->comments->contains( $comment ) ) {
|
||||
$this->comments[] = $comment;
|
||||
$comment->setPoll( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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
|
||||
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->stacksOfVotes;
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function setStacksOfVotes(?StackOfVotes $stacksOfVotes): self
|
||||
public function addStackOfVote(StackOfVotes $stackOfVote): self
|
||||
{
|
||||
$this->stacksOfVotes = $stacksOfVotes;
|
||||
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;
|
||||
}
|
||||
|
@ -7,111 +7,80 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* contains the votes for one answer to a poll
|
||||
* @ORM\Entity(repositoryClass="App\Repository\StackOfVotesRepository")
|
||||
*/
|
||||
class StackOfVotes
|
||||
{
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
class StackOfVotes {
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\poll", mappedBy="stacksOfVotes")
|
||||
*/
|
||||
private $votes;
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\poll", mappedBy="stacksOfVotes")
|
||||
*/
|
||||
private $votes;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $pseudo;
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Owner", inversedBy="stackOfVotes")
|
||||
*/
|
||||
private $owner;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $modifierToken;
|
||||
public function __construct() {
|
||||
$this->votes = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Owner", inversedBy="stackOfVotes")
|
||||
*/
|
||||
private $owner;
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->votes = new ArrayCollection();
|
||||
}
|
||||
/**
|
||||
* @return Collection|poll[]
|
||||
*/
|
||||
public function getVotes(): Collection {
|
||||
return $this->votes;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
public function addVote( poll $vote ): self {
|
||||
if ( ! $this->votes->contains( $vote ) ) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setStacksOfVotes( $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|poll[]
|
||||
*/
|
||||
public function getVotes(): Collection
|
||||
{
|
||||
return $this->votes;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addVote(poll $vote): self
|
||||
{
|
||||
if (!$this->votes->contains($vote)) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setStacksOfVotes($this);
|
||||
}
|
||||
public function removeVote( poll $vote ): self {
|
||||
if ( $this->votes->contains( $vote ) ) {
|
||||
$this->votes->removeElement( $vote );
|
||||
// set the owning side to null (unless already changed)
|
||||
if ( $vote->getStacksOfVotes() === $this ) {
|
||||
$vote->setStacksOfVotes( null );
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeVote(poll $vote): self
|
||||
{
|
||||
if ($this->votes->contains($vote)) {
|
||||
$this->votes->removeElement($vote);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($vote->getStacksOfVotes() === $this) {
|
||||
$vote->setStacksOfVotes(null);
|
||||
}
|
||||
}
|
||||
public function getPseudo(): ?string {
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function setPseudo( ?string $pseudo ): self {
|
||||
$this->pseudo = $pseudo;
|
||||
|
||||
public function getPseudo(): ?string
|
||||
{
|
||||
return $this->pseudo;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPseudo(?string $pseudo): self
|
||||
{
|
||||
$this->pseudo = $pseudo;
|
||||
public function getOwner(): ?Owner {
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function setOwner( ?Owner $owner ): self {
|
||||
$this->owner = $owner;
|
||||
|
||||
public function getModifierToken(): ?string
|
||||
{
|
||||
return $this->modifierToken;
|
||||
}
|
||||
|
||||
public function setModifierToken(string $modifierToken): self
|
||||
{
|
||||
$this->modifierToken = $modifierToken;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOwner(): ?Owner
|
||||
{
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function setOwner(?Owner $owner): self
|
||||
{
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
@ -9,84 +10,47 @@ use JMS\Serializer\Annotation as Serializer;
|
||||
* @ORM\Entity(repositoryClass="App\Repository\VoteRepository")
|
||||
*/
|
||||
class Vote {
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Type("integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $pseudo;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
* @Serializer\Type("string")
|
||||
*/
|
||||
public $answerTxt;
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
* @Serializer\Type("datetime")
|
||||
*/
|
||||
private $answerDate;
|
||||
|
||||
public $value;
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
* @Serializer\Type("datetime")
|
||||
*/
|
||||
public $creationDate;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Poll", inversedBy="votes")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Type("App\Entity\Poll")
|
||||
*/
|
||||
private $poll;
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Choice", inversedBy="votes")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Type("App\Entity\choice")
|
||||
*/
|
||||
public $choice;
|
||||
/**
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue()
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Type("integer")
|
||||
*/
|
||||
private $id;
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Entity\Poll", inversedBy="votes")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Type("App\Entity\Poll")
|
||||
*/
|
||||
private $poll;
|
||||
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getAnswerTxt(): ?string {
|
||||
return $this->answerTxt;
|
||||
}
|
||||
|
||||
public function setAnswerTxt( ?string $answerTxt ): self {
|
||||
$this->answerTxt = $answerTxt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAnswerDate(): ?\DateTimeInterface {
|
||||
return $this->answerDate;
|
||||
}
|
||||
|
||||
public function setAnswerDate( ?\DateTimeInterface $answerDate ): self {
|
||||
$this->answerDate = $answerDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreationDate(): ?\DateTimeInterface {
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
public function setCreationDate( \DateTimeInterface $creationDate ): self {
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPoll(): ?Poll {
|
||||
return $this->poll;
|
||||
}
|
||||
@ -116,4 +80,24 @@ class Vote {
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getValue(): ?string {
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue( ?string $value ): self {
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreationDate(): ?DateTimeInterface {
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
public function setCreationDate( DateTimeInterface $creationDate ): self {
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user