mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
batch of answers in fixtures
This commit is contained in:
parent
c0e7173326
commit
eba4a14ce8
@ -7,6 +7,7 @@ use App\Entity\Owner;
|
||||
use App\Entity\Poll;
|
||||
use App\Entity\StackOfVotes;
|
||||
use App\Entity\Vote;
|
||||
use DateTime;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
@ -22,15 +23,14 @@ class AppPollFixtures extends Fixture {
|
||||
->setPseudo( 'voting_people_TEST' )
|
||||
->setModifierToken( uniqid() );
|
||||
|
||||
// $product = new Product();
|
||||
$poll = new Poll();
|
||||
$poll->setTitle( 'citron ou orange' );
|
||||
$poll->setKind( 'text' );
|
||||
$poll->setDescription( 'votre sorbert préféré' );
|
||||
$poll->setAdminKey( uniqid() );
|
||||
$poll->setModificationPolicy( 'nobody' );
|
||||
$poll->setCreationDate( new \DateTime() );
|
||||
$poll->setExpiracyDate( new \DateTime() );
|
||||
|
||||
$poll->setExpiracyDate( new DateTime() );
|
||||
$poll->setMailOnVote( true );
|
||||
$poll->setOwner( $owner );
|
||||
$owner->addPoll( $poll );
|
||||
@ -46,11 +46,9 @@ class AppPollFixtures extends Fixture {
|
||||
|
||||
$voteA = new Vote();
|
||||
$voteA->setPseudo( 'chuck norris' )
|
||||
->setCreationDate( new DateTime() )
|
||||
->setChoice( $choiceA );
|
||||
$voteA = new Vote();
|
||||
$voteA->setPseudo( 'Néo' )
|
||||
->setCreationDate( new DateTime() )
|
||||
->setChoice( $choiceB );
|
||||
|
||||
$manager->persist( $poll );
|
||||
@ -63,13 +61,13 @@ class AppPollFixtures extends Fixture {
|
||||
$poll->setAdminKey( uniqid() );
|
||||
$poll->setModificationPolicy( 'self' );
|
||||
$poll->setMailOnComment( true );
|
||||
$poll->setCreationDate( new \DateTime() );
|
||||
$poll->setExpiracyDate( new \DateTime() );
|
||||
$poll->setExpiracyDate( new DateTime() );
|
||||
$poll->setOwner( $owner );
|
||||
$owner->addPoll( $poll );
|
||||
|
||||
$manager->persist( $poll );
|
||||
|
||||
|
||||
// voting test with 2 people
|
||||
$stack1 = new StackOfVotes();
|
||||
$stack1->setOwner( $voter )
|
||||
@ -89,8 +87,8 @@ class AppPollFixtures extends Fixture {
|
||||
$poll->setDescription( 'description du sondage a accès restreint. le mot de passe est mot_de_passe_super' );
|
||||
$poll->setAdminKey( uniqid() );
|
||||
$poll->setCustomUrl( 'boudoum_podom_podom' );
|
||||
$poll->setCreationDate( new \DateTime() );
|
||||
$poll->setExpiracyDate( new \DateTime() );
|
||||
|
||||
$poll->setExpiracyDate( new DateTime() );
|
||||
$poll->setMailOnComment( true );
|
||||
$poll->setMailOnVote( true );
|
||||
$poll->setOwner( $owner );
|
||||
@ -100,6 +98,24 @@ class AppPollFixtures extends Fixture {
|
||||
$manager->persist( $owner );
|
||||
$manager->persist( $voter );
|
||||
|
||||
|
||||
// poll with cartoon choices
|
||||
$poll = new Poll();
|
||||
$poll->setTitle( 'dessin animé préféré' )
|
||||
->setDescription( 'choisissez votre animé préféré' )
|
||||
->addTextChoiceArray( [
|
||||
"Vic le viking",
|
||||
"Boumbo petite automobile",
|
||||
"Les mystérieuses cités d'or",
|
||||
"Les mondes engloutis",
|
||||
"Foot 2 rue",
|
||||
"Le chat, la vache, et l'océan",
|
||||
"Digimon",
|
||||
],
|
||||
'fixture land' );
|
||||
|
||||
$manager->persist( $poll );
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
|
@ -50,120 +50,118 @@ class Choice {
|
||||
private $vote;
|
||||
|
||||
public function __construct() {
|
||||
$this->poll = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
$this->vote = new ArrayCollection();
|
||||
}
|
||||
$this->poll = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
$this->vote = new ArrayCollection();
|
||||
$this->setDateTime( new \DateTime() );
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateTime(): ?DateTimeInterface {
|
||||
return $this->dateTime;
|
||||
}
|
||||
return $this->dateTime;
|
||||
}
|
||||
|
||||
public function setDateTime( ?DateTimeInterface $dateTime ): self {
|
||||
$this->dateTime = $dateTime;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$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 getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function addVote( Choice $vote ): self {
|
||||
if ( ! $this->stackOfVotes->contains( $vote ) ) {
|
||||
$this->stackOfVotes[] = $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->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;
|
||||
}
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
public function addStackOfVote(StackOfVotes $stackOfVote): self
|
||||
{
|
||||
if (!$this->stackOfVotes->contains($stackOfVote)) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setChoice($this);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function addStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setChoice( $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 $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 Collection|Vote[]
|
||||
*/
|
||||
public function getVote(): Collection
|
||||
{
|
||||
return $this->vote;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Vote[]
|
||||
*/
|
||||
public function getVote(): Collection {
|
||||
return $this->vote;
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,14 @@ class Poll {
|
||||
* @Serializer\Expose()
|
||||
*/
|
||||
public $kind;
|
||||
/**
|
||||
* array of possible answer to each choice, by default: "yes" or nothing only.
|
||||
* could be also "yes", "maybe", "no". extensible to anything
|
||||
* @ORM\Column(type="array")
|
||||
* @Serializer\Type("string")
|
||||
* @Serializer\Expose()
|
||||
*/
|
||||
public $allowedAnswers;
|
||||
/**
|
||||
* kind of way the people can modify the poll
|
||||
* everybody - can modify votes
|
||||
@ -131,280 +139,300 @@ class Poll {
|
||||
private $stacksOfVotes;
|
||||
|
||||
public function __construct() {
|
||||
$this->votes = new ArrayCollection();
|
||||
$this->choices = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
}
|
||||
$this->votes = new ArrayCollection();
|
||||
$this->choices = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
$this->stackOfVotes = new ArrayCollection();
|
||||
$this->setCreationDate( new \DateTime() );
|
||||
$this->setAllowedAnswers( [ 'yes' ] );
|
||||
}
|
||||
|
||||
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;
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreationDate(): ?DateTimeInterface {
|
||||
return $this->creationDate;
|
||||
}
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
public function setCreationDate( DateTimeInterface $creationDate ): self {
|
||||
$this->creationDate = $creationDate;
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setExpiracyDate( DateTimeInterface $expiracyDate ): self {
|
||||
$this->expiracyDate = $expiracyDate;
|
||||
$this->expiracyDate = $expiracyDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOwner(): ?Owner {
|
||||
return $this->owner;
|
||||
}
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function setOwner( ?Owner $owner ): self {
|
||||
$this->owner = $owner;
|
||||
$this->owner = $owner;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Vote[]
|
||||
*/
|
||||
public function getVotes(): Collection {
|
||||
return $this->votes;
|
||||
}
|
||||
return $this->votes;
|
||||
}
|
||||
|
||||
|
||||
public function getAdminKey(): ?string {
|
||||
return $this->adminKey;
|
||||
}
|
||||
return $this->adminKey;
|
||||
}
|
||||
|
||||
public function setAdminKey( string $adminKey ): self {
|
||||
$this->adminKey = $adminKey;
|
||||
$this->adminKey = $adminKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string {
|
||||
return $this->description;
|
||||
}
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription( string $description ): self {
|
||||
$this->description = $description;
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getKind(): ?string {
|
||||
return $this->kind;
|
||||
}
|
||||
return $this->kind;
|
||||
}
|
||||
|
||||
public function setKind( string $kind ): self {
|
||||
$this->kind = $kind;
|
||||
$this->kind = $kind;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCustomUrl(): ?string {
|
||||
return $this->customUrl;
|
||||
}
|
||||
return $this->customUrl;
|
||||
}
|
||||
|
||||
public function setCustomUrl( string $customUrl ): self {
|
||||
$this->customUrl = $customUrl;
|
||||
$this->customUrl = $customUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassword(): ?string {
|
||||
return $this->password;
|
||||
}
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword( string $password ): self {
|
||||
$this->password = $password;
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getModificationPolicy(): ?string {
|
||||
return $this->modificationPolicy;
|
||||
}
|
||||
return $this->modificationPolicy;
|
||||
}
|
||||
|
||||
public function setModificationPolicy( string $modificationPolicy ): self {
|
||||
$this->modificationPolicy = $modificationPolicy;
|
||||
$this->modificationPolicy = $modificationPolicy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMailOnComment(): ?bool {
|
||||
return $this->mailOnComment;
|
||||
}
|
||||
return $this->mailOnComment;
|
||||
}
|
||||
|
||||
public function setMailOnComment( bool $mailOnComment ): self {
|
||||
$this->mailOnComment = $mailOnComment;
|
||||
$this->mailOnComment = $mailOnComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMailOnVote(): ?bool {
|
||||
return $this->mailOnVote;
|
||||
}
|
||||
return $this->mailOnVote;
|
||||
}
|
||||
|
||||
public function setMailOnVote( bool $mailOnVote ): self {
|
||||
$this->mailOnVote = $mailOnVote;
|
||||
$this->mailOnVote = $mailOnVote;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHideResults(): ?bool {
|
||||
return $this->hideResults;
|
||||
}
|
||||
return $this->hideResults;
|
||||
}
|
||||
|
||||
public function setHideResults( bool $hideResults ): self {
|
||||
$this->hideResults = $hideResults;
|
||||
$this->hideResults = $hideResults;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowResultEvenIfPasswords(): ?bool {
|
||||
return $this->showResultEvenIfPasswords;
|
||||
}
|
||||
return $this->showResultEvenIfPasswords;
|
||||
}
|
||||
|
||||
public function setShowResultEvenIfPasswords( bool $showResultEvenIfPasswords ): self {
|
||||
$this->showResultEvenIfPasswords = $showResultEvenIfPasswords;
|
||||
$this->showResultEvenIfPasswords = $showResultEvenIfPasswords;
|
||||
|
||||
return $this;
|
||||
}
|
||||
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 );
|
||||
}
|
||||
if ( ! $this->comments->contains( $comment ) ) {
|
||||
$this->comments[] = $comment;
|
||||
$comment->setPoll( $this );
|
||||
}
|
||||
|
||||
return $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 );
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStacksOfVotes(): ?StackOfVotes {
|
||||
return $this->stacksOfVotes;
|
||||
}
|
||||
return $this->stacksOfVotes;
|
||||
}
|
||||
|
||||
public function setStacksOfVotes( ?StackOfVotes $stacksOfVotes ): self {
|
||||
$this->stacksOfVotes = $stacksOfVotes;
|
||||
$this->stacksOfVotes = $stacksOfVotes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|StackOfVotes[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function addStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setPoll( $this );
|
||||
}
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setPoll( $this );
|
||||
}
|
||||
|
||||
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->getPoll() === $this ) {
|
||||
$stackOfVote->setPoll( null );
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExpiracyDate(): ?\DateTimeInterface {
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
|
||||
public function addVote( Vote $vote ): self {
|
||||
if ( ! $this->votes->contains( $vote ) ) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setPoll( $this );
|
||||
}
|
||||
if ( ! $this->votes->contains( $vote ) ) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setPoll( $this );
|
||||
}
|
||||
|
||||
return $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 );
|
||||
}
|
||||
}
|
||||
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 $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|Choice[]
|
||||
*/
|
||||
public function getChoices(): Collection
|
||||
{
|
||||
return $this->choices;
|
||||
}
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
public function addTextChoiceArray( Array $choiceTextArray, $pseudo = "some body" ): self {
|
||||
foreach ( $choiceTextArray as $text ) {
|
||||
$newChoice = new Choice();
|
||||
$newChoice->setName( $text )
|
||||
->setPseudo( $pseudo );
|
||||
$this->addChoice( $newChoice );
|
||||
}
|
||||
|
||||
return $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);
|
||||
}
|
||||
}
|
||||
public function addChoice( Choice $choice ): self {
|
||||
if ( ! $this->choices->contains( $choice ) ) {
|
||||
$this->choices[] = $choice;
|
||||
$choice->setPoll( $this );
|
||||
}
|
||||
|
||||
return $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;
|
||||
}
|
||||
|
||||
public function getAllowedAnswers(): ?array {
|
||||
return $this->allowedAnswers;
|
||||
}
|
||||
|
||||
public function setAllowedAnswers( array $allowedAnswers ): self {
|
||||
$this->allowedAnswers = $allowedAnswers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ class Vote {
|
||||
*/
|
||||
private $poll;
|
||||
|
||||
public function __construct() {
|
||||
$this->setCreationDate( new \DateTime() );
|
||||
}
|
||||
|
||||
public function getId(): ?int {
|
||||
return $this->id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user