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',
|
||||
|
@ -161,10 +161,6 @@ class Poll {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExpiracyDate(): ?DateTimeInterface {
|
||||
return $this->expiracyDate;
|
||||
}
|
||||
|
||||
public function setExpiracyDate( DateTimeInterface $expiracyDate ): self {
|
||||
$this->expiracyDate = $expiracyDate;
|
||||
|
||||
@ -188,26 +184,6 @@ class Poll {
|
||||
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;
|
||||
@ -309,33 +285,6 @@ class Poll {
|
||||
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[]
|
||||
@ -378,13 +327,11 @@ class Poll {
|
||||
/**
|
||||
* @return Collection|StackOfVotes[]
|
||||
*/
|
||||
public function getStackOfVotes(): Collection
|
||||
{
|
||||
public function getStackOfVotes(): Collection {
|
||||
return $this->stackOfVotes;
|
||||
}
|
||||
|
||||
public function addStackOfVote(StackOfVotes $stackOfVote): self
|
||||
{
|
||||
public function addStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( ! $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes[] = $stackOfVote;
|
||||
$stackOfVote->setPoll( $this );
|
||||
@ -393,8 +340,7 @@ class Poll {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeStackOfVote(StackOfVotes $stackOfVote): self
|
||||
{
|
||||
public function removeStackOfVote( StackOfVotes $stackOfVote ): self {
|
||||
if ( $this->stackOfVotes->contains( $stackOfVote ) ) {
|
||||
$this->stackOfVotes->removeElement( $stackOfVote );
|
||||
// set the owning side to null (unless already changed)
|
||||
@ -403,6 +349,62 @@ class Poll {
|
||||
}
|
||||
}
|
||||
|
||||
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|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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user