mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
hop
This commit is contained in:
parent
216d1902cc
commit
e2846a6c73
@ -215,6 +215,50 @@ class DefaultController extends AbstractController {
|
||||
201 );
|
||||
}
|
||||
|
||||
/**
|
||||
* add a comment on a poll
|
||||
* @Post(
|
||||
* path = "poll/{id}/vote",
|
||||
* name = "new_vote_stack",
|
||||
* requirements = {"content"="\w+", "poll_id"="\d+"}
|
||||
* )
|
||||
*/
|
||||
public function newVoteStackAction( Poll $poll, Request $request ) {
|
||||
// if ( ! $poll ) {
|
||||
// return $this->json( [ 'message' => 'poll not found' ], 404 );
|
||||
// }
|
||||
// $data = $request->getContent();
|
||||
//
|
||||
// $serializer = SerializerBuilder::create()->build();
|
||||
// $comment = $serializer->deserialize( $data, 'App\Entity\Comment', 'json' );
|
||||
//
|
||||
// $em = $this->getDoctrine()->getRepository( Owner::class );
|
||||
//
|
||||
// $data = json_decode( $data, true );
|
||||
//
|
||||
// $foundOwner = $em->findByEmail( $data[ 'owner' ][ 'email' ] );
|
||||
// // manage existing or new Owner
|
||||
// if ( ! $foundOwner ) {
|
||||
// $foundOwner = new Owner();
|
||||
// $foundOwner->setPseudo( $data[ 'owner' ][ 'email' ] )
|
||||
// ->setEmail( $data[ 'owner' ][ 'email' ] )
|
||||
// ->setModifierToken( uniqid() );
|
||||
// }
|
||||
// $comment->setOwner( $foundOwner )
|
||||
// ->setPoll( $poll );
|
||||
// $foundOwner->addComment( $comment );
|
||||
//
|
||||
// $em = $this->getDoctrine()->getManager();
|
||||
// $em->persist( $foundOwner );
|
||||
// $em->persist( $comment );
|
||||
// $em->flush();
|
||||
|
||||
return $this->json( [
|
||||
'message' => 'you created a comment',
|
||||
],
|
||||
201 );
|
||||
}
|
||||
|
||||
function newVoteAction( Poll $poll ) {
|
||||
return $this->json( [
|
||||
'message' => 'you voted on the poll',
|
||||
|
@ -131,275 +131,277 @@ 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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
return $this->creationDate;
|
||||
}
|
||||
|
||||
public function setCreationDate( DateTimeInterface $creationDate ): self {
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExpiracyDate(): ?DateTimeInterface {
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
$this->creationDate = $creationDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setExpiracyDate( DateTimeInterface $expiracyDate ): self {
|
||||
$this->expiracyDate = $expiracyDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public function addChoice( Choice $choice ): self {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 {
|
||||
return $this->stacksOfVotes;
|
||||
}
|
||||
return $this->stacksOfVotes;
|
||||
}
|
||||
|
||||
public function setStacksOfVotes( ?StackOfVotes $stacksOfVotes ): self {
|
||||
$this->stacksOfVotes = $stacksOfVotes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
$this->stacksOfVotes = $stacksOfVotes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|StackOfVotes[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function addStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
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;
|
||||
}
|
||||
|
||||
public function getExpiracyDate(): ?\DateTimeInterface {
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|StackOfVotes[]
|
||||
* @return Collection|Choice[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection
|
||||
public function getChoices(): Collection
|
||||
{
|
||||
return $this->stackOfVotes;
|
||||
return $this->choices;
|
||||
}
|
||||
|
||||
public function addStackOfVote(StackOfVotes $stackOfVote): self
|
||||
public function addChoice(Choice $choice): self
|
||||
{
|
||||
if (!$this->stackOfVotes->contains($stackOfVote)) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setPoll($this);
|
||||
if (!$this->choices->contains($choice)) {
|
||||
$this->choices[] = $choice;
|
||||
$choice->setPoll($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeStackOfVote(StackOfVotes $stackOfVote): self
|
||||
public function removeChoice(Choice $choice): self
|
||||
{
|
||||
if ($this->stackOfVotes->contains($stackOfVote)) {
|
||||
$this->stackOfVotes->removeElement($stackOfVote);
|
||||
if ($this->choices->contains($choice)) {
|
||||
$this->choices->removeElement($choice);
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($stackOfVote->getPoll() === $this) {
|
||||
$stackOfVote->setPoll(null);
|
||||
if ($choice->getPoll() === $this) {
|
||||
$choice->setPoll(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user