mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
⚡ fixture with polls and owner
This commit is contained in:
parent
85f643bcce
commit
452083c74c
@ -131,4 +131,23 @@ class DefaultController extends AbstractController {
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
public function deletePollAction() {
|
||||
return $this->json( [
|
||||
'message' => 'boom',
|
||||
] );
|
||||
}
|
||||
|
||||
public function deletePollCommentsAction() {
|
||||
return $this->json( [
|
||||
'message' => 'boom',
|
||||
] );
|
||||
}
|
||||
|
||||
public function deletePollVotesAction() {
|
||||
return $this->json( [
|
||||
'message' => 'boom',
|
||||
] );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,21 +2,65 @@
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\Owner;
|
||||
use App\Entity\Poll;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
class AppPollFixtures extends Fixture {
|
||||
public function load( ObjectManager $manager ) {
|
||||
|
||||
$owner = new Owner();
|
||||
$owner->setEmail( 'tktest@tktest.com' )
|
||||
->setPseudo( 'tk_TEST' );
|
||||
|
||||
// $product = new Product();
|
||||
$poll = new Poll();
|
||||
$poll->setTitle( 'démo sondage de texte' );
|
||||
$poll->setKind( 'text' );
|
||||
$poll->setDescription( 'description du sondage' );
|
||||
$poll->setAdminKey( 'dskjfsfdljkdsjlkdsfkjdsjdlkfs' );
|
||||
$poll->setModificationPolicy( 'nobody' );
|
||||
$poll->setCreationDate( new \DateTime() );
|
||||
|
||||
$poll->setExpiracyDate( new \DateTime( ( time() + 3600 * 24 ) ) );
|
||||
$poll->setExpiracyDate( new \DateTime() );
|
||||
$poll->setMailOnVote( true );
|
||||
$poll->setOwner( $owner );
|
||||
$owner->addPoll( $poll );
|
||||
|
||||
$manager->persist( $poll );
|
||||
|
||||
|
||||
$poll = new Poll();
|
||||
$poll->setTitle( 'démo sondage de texte 2' );
|
||||
$poll->setDescription( 'description du sondage 2' );
|
||||
$poll->setKind( 'date' );
|
||||
$poll->setAdminKey( 'dskjfsfdljkdsjlkdsfkjdsjdlkfs' );
|
||||
$poll->setModificationPolicy( 'self' );
|
||||
$poll->setMailOnComment( true );
|
||||
$poll->setCreationDate( new \DateTime() );
|
||||
$poll->setExpiracyDate( new \DateTime() );
|
||||
$poll->setOwner( $owner );
|
||||
$owner->addPoll( $poll );
|
||||
|
||||
$manager->persist( $poll );
|
||||
|
||||
$poll = new Poll();
|
||||
$poll->setTitle( 'accès restreint sondage de texte' );
|
||||
$poll->setKind( 'text' );
|
||||
$poll->setPassword( md5( 'mot_de_passe_super' ) );
|
||||
$poll->setModificationPolicy( 'everybody' );
|
||||
$poll->setDescription( 'description du sondage' );
|
||||
$poll->setAdminKey( 'dskjfsfdljkdsjlkdsfkjdsjdlkfs' );
|
||||
$poll->setCreationDate( new \DateTime() );
|
||||
$poll->setExpiracyDate( new \DateTime() );
|
||||
$poll->setMailOnComment( true );
|
||||
$poll->setMailOnVote( true );
|
||||
$poll->setOwner( $owner );
|
||||
$owner->addPoll( $poll );
|
||||
|
||||
$manager->persist( $poll );
|
||||
$manager->persist( $owner );
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,20 @@ class Poll {
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $title;
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $customUrl;
|
||||
|
||||
/**
|
||||
* vote restricted by a password
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $password;
|
||||
/**
|
||||
* @ORM\Column(type="string", length=1000)
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
@ -43,14 +57,46 @@ class Poll {
|
||||
* @ORM\Column(type="string", length=255)
|
||||
*/
|
||||
private $adminKey;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="App\Entity\Vote", mappedBy="poll", orphanRemoval=true)
|
||||
*/
|
||||
private $votes;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct() {
|
||||
$this->votes = new ArrayCollection();
|
||||
}
|
||||
|
||||
@ -101,31 +147,128 @@ class Poll {
|
||||
/**
|
||||
* @return Collection|Vote[]
|
||||
*/
|
||||
public function getVotes(): Collection
|
||||
{
|
||||
public function getVotes(): Collection {
|
||||
return $this->votes;
|
||||
}
|
||||
|
||||
public function addVote(Vote $vote): self
|
||||
{
|
||||
if (!$this->votes->contains($vote)) {
|
||||
public function addVote( Vote $vote ): self {
|
||||
if ( ! $this->votes->contains( $vote ) ) {
|
||||
$this->votes[] = $vote;
|
||||
$vote->setPoll($this);
|
||||
$vote->setPoll( $this );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeVote(Vote $vote): self
|
||||
{
|
||||
if ($this->votes->contains($vote)) {
|
||||
$this->votes->removeElement($vote);
|
||||
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 ( $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;
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,18 @@ class Vote {
|
||||
public function setPoll( ?Poll $poll ): self {
|
||||
$this->poll = $poll;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPseudo(): ?string
|
||||
{
|
||||
return $this->pseudo;
|
||||
}
|
||||
|
||||
public function setPseudo(?string $pseudo): self
|
||||
{
|
||||
$this->pseudo = $pseudo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user