1
0
mirror of https://framagit.org/tykayn/date-poll-api synced 2023-08-25 08:23:11 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
1bc69f56ad start vote stack adding votes 2021-04-28 18:49:40 +02:00
272588d000 update doctrine managerregistry 2021-04-28 18:40:04 +02:00
d63929eb93 find a poll by custom url in vote stack add action 2021-04-28 16:20:40 +02:00
2733c1f2a3 enable cors 2021-04-28 16:12:44 +02:00
13 changed files with 281 additions and 414 deletions

143
composer.lock generated
View File

@ -59,24 +59,6 @@
} }
], ],
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"support": {
"issues": "https://github.com/composer/package-versions-deprecated/issues",
"source": "https://github.com/composer/package-versions-deprecated/tree/1.11.99.1"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2020-11-11T10:22:58+00:00" "time": "2020-11-11T10:22:58+00:00"
}, },
{ {
@ -229,24 +211,6 @@
"redis", "redis",
"xcache" "xcache"
], ],
"support": {
"issues": "https://github.com/doctrine/cache/issues",
"source": "https://github.com/doctrine/cache/tree/1.10.x"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache",
"type": "tidelift"
}
],
"time": "2020-07-07T18:54:01+00:00" "time": "2020-07-07T18:54:01+00:00"
}, },
{ {
@ -312,10 +276,6 @@
"iterators", "iterators",
"php" "php"
], ],
"support": {
"issues": "https://github.com/doctrine/collections/issues",
"source": "https://github.com/doctrine/collections/tree/1.6.7"
},
"time": "2020-07-27T17:53:49+00:00" "time": "2020-07-27T17:53:49+00:00"
}, },
{ {
@ -825,24 +785,6 @@
"event system", "event system",
"events" "events"
], ],
"support": {
"issues": "https://github.com/doctrine/event-manager/issues",
"source": "https://github.com/doctrine/event-manager/tree/1.1.x"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager",
"type": "tidelift"
}
],
"time": "2020-05-29T18:28:51+00:00" "time": "2020-05-29T18:28:51+00:00"
}, },
{ {
@ -989,24 +931,6 @@
"constructor", "constructor",
"instantiate" "instantiate"
], ],
"support": {
"issues": "https://github.com/doctrine/instantiator/issues",
"source": "https://github.com/doctrine/instantiator/tree/1.4.0"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator",
"type": "tidelift"
}
],
"time": "2020-11-10T18:47:58+00:00" "time": "2020-11-10T18:47:58+00:00"
}, },
{ {
@ -1069,24 +993,6 @@
"parser", "parser",
"php" "php"
], ],
"support": {
"issues": "https://github.com/doctrine/lexer/issues",
"source": "https://github.com/doctrine/lexer/tree/1.2.1"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer",
"type": "tidelift"
}
],
"time": "2020-05-25T17:44:05+00:00" "time": "2020-05-25T17:44:05+00:00"
}, },
{ {
@ -1418,10 +1324,6 @@
"highlight", "highlight",
"sql" "sql"
], ],
"support": {
"issues": "https://github.com/doctrine/sql-formatter/issues",
"source": "https://github.com/doctrine/sql-formatter/tree/1.1.x"
},
"time": "2020-07-30T16:57:33+00:00" "time": "2020-07-30T16:57:33+00:00"
}, },
{ {
@ -2424,9 +2326,6 @@
"psr", "psr",
"psr-3" "psr-3"
], ],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.3"
},
"time": "2020-03-23T09:12:05+00:00" "time": "2020-03-23T09:12:05+00:00"
}, },
{ {
@ -2767,7 +2666,6 @@
"suggest": { "suggest": {
"symfony/cache-implementation": "" "symfony/cache-implementation": ""
}, },
"default-branch": true,
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
@ -3136,23 +3034,6 @@
], ],
"description": "A generic function and convention to trigger deprecation notices", "description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/master"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2020-09-07T11:33:47+00:00" "time": "2020-09-07T11:33:47+00:00"
}, },
{ {
@ -6371,10 +6252,6 @@
} }
], ],
"description": "JSONP callback validator.", "description": "JSONP callback validator.",
"support": {
"issues": "https://github.com/willdurand/JsonpCallbackValidator/issues",
"source": "https://github.com/willdurand/JsonpCallbackValidator/tree/master"
},
"time": "2014-01-20T22:35:06+00:00" "time": "2014-01-20T22:35:06+00:00"
}, },
{ {
@ -6573,24 +6450,6 @@
"Fixture", "Fixture",
"persistence" "persistence"
], ],
"support": {
"issues": "https://github.com/doctrine/DoctrineFixturesBundle/issues",
"source": "https://github.com/doctrine/DoctrineFixturesBundle/tree/3.4.0"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdoctrine-fixtures-bundle",
"type": "tidelift"
}
],
"time": "2020-11-14T09:36:49+00:00" "time": "2020-11-14T09:36:49+00:00"
}, },
{ {
@ -6749,5 +6608,5 @@
"ext-iconv": "*" "ext-iconv": "*"
}, },
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.0.0" "plugin-api-version": "1.1.0"
} }

View File

@ -1,10 +1,24 @@
nelmio_cors: nelmio_cors:
defaults: defaults:
origin_regex: true allow_credentials: false
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] allow_origin: []
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] allow_headers: []
allow_headers: ['Content-Type', 'Authorization'] allow_methods: []
expose_headers: ['Link'] expose_headers: []
max_age: 3600 max_age: 0
hosts: []
origin_regex: false
forced_allow_origin_value: ~
paths: paths:
'^/': null '^/api/':
allow_origin: ['*']
allow_headers: ['*']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'OPTIONS']
max_age: 3600
'^/':
origin_regex: true
allow_origin: ['^http://localhost:[0-9]+']
allow_headers: ['*']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'OPTIONS']
max_age: 3600
hosts: ['^api\.']

View File

@ -1,15 +0,0 @@
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null
'^/api/':
allow_origin: ['*']
allow_headers: ['X-Custom-Auth']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
max_age: 3600

View File

@ -6,8 +6,8 @@
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
header( 'Access-Control-Allow-Origin: *' ); header( 'Access-Control-Allow-Origin: *' );
header( "Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method" ); // header( "Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method" );
header( "Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE" ); // header( "Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE" );
header( "Allow: GET, POST, OPTIONS, PUT, DELETE" ); header( "Allow: GET, POST, OPTIONS, PUT, DELETE" );
$method = $_SERVER[ 'REQUEST_METHOD' ]; $method = $_SERVER[ 'REQUEST_METHOD' ];
if ( $method == "OPTIONS" ) { if ( $method == "OPTIONS" ) {

View File

@ -1,223 +1,269 @@
<?php <?php
namespace App\Controller\api; namespace App\Controller\api;
use App\Controller\EmailsController; use App\Controller\EmailsController;
use App\Entity\Choice; use App\Entity\Choice;
use App\Entity\Owner; use App\Entity\Owner;
use App\Entity\Poll; use App\Entity\Poll;
use App\Entity\StackOfVotes; use App\Entity\StackOfVotes;
use App\Entity\Vote; use App\Entity\Vote;
use FOS\RestBundle\Controller\Annotations\Delete; use App\Repository\ChoiceRepository;
use FOS\RestBundle\Controller\Annotations\Patch; use FOS\RestBundle\Controller\Annotations\Delete;
use FOS\RestBundle\Controller\Annotations\Post; use FOS\RestBundle\Controller\Annotations\Patch;
use FOS\RestBundle\Controller\Annotations\Route; use FOS\RestBundle\Controller\Annotations\Post;
use JMS\Serializer\SerializerInterface; use FOS\RestBundle\Controller\Annotations\Route;
use Symfony\Component\HttpFoundation\JsonResponse; use JMS\Serializer\SerializerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/** use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* Class DefaultController
* @package App\Controller
* @Route("/api/v1",name="api_")
*/
class VoteController extends EmailsController {
/** /**
* add a vote stack on a poll * Class DefaultController
* @Post( * @package App\Controller
* path = "/poll/{id}/answer", * @Route("/api/v1",name="api_")
* name = "new_vote_stack",
* requirements = {"content"="\w+", "poll_id"="\d+"}
* )
*
* @param SerializerInterface $serializer
* @param Poll $poll
* @param Request $request
*
* @return JsonResponse|Response
*/ */
public function newVoteStackAction( class VoteController extends EmailsController {
SerializerInterface $serializer,
Poll $poll,
Request $request
) {
if ( ! $poll ) {
return $this->json( [ 'message' => 'poll not found' ], 404 );
}
$em = $this->getDoctrine()->getManager(); /**
$data = $request->getContent(); * add a vote stack on a poll
$data = json_decode( $data, true ); * @Post(
* path = "/poll/{custom_url}/answer",
* name = "new_vote_stack",
* )
*
* @param SerializerInterface $serializer
* @param string $custom_url
* @param Request $request
*
* @return JsonResponse|Response
*/
public function newVoteStackAction(
SerializerInterface $serializer,
string $custom_url,
Request $request,
ChoiceRepository $choice_repository,
) {
$emOwner = $this->getDoctrine()->getRepository( Owner::class ); $em = $this->getDoctrine()->getManager();
$emChoice = $this->getDoctrine()->getRepository( Choice::class ); $emPol = $em->getRepository( Poll::class );
$existingOwner = false; $poll = $emPol->findOneByCustomUrl( $custom_url );
$foundOwner = $emOwner->findOneByEmail( trim( $data[ 'email' ] ) );
// manage existing or new Owner
if ( ! $foundOwner ) {
$foundOwner = new Owner();
$foundOwner
->setEmail( $data[ 'email' ] )
->setPseudo( $data[ 'pseudo' ] );
} else {
$existingOwner = true;
}
// TODO anti flood
$foundOwner
->setModifierToken( $poll->generateRandomKey() );
$stack = new StackOfVotes();
$stack
->setOwner( $foundOwner )
->setIp( $_SERVER[ 'REMOTE_ADDR' ] )
->setPseudo( $data[ 'pseudo' ] )
->setPoll( $poll );
foreach ( $data[ 'votes' ] as $voteInfo ) {
if ( ! isset( $voteInfo[ 'value' ] ) ) { if ( ! $poll ) {
continue; return $this->json( [ 'message' => 'poll "' . $custom_url . '" not found' ], 404 );
} }
$allowedValuesToAnswer = [ 'yes', 'maybe', 'no' ];
if ( ! in_array( $voteInfo[ 'value' ], $allowedValuesToAnswer ) ) { $data = $request->getContent();
return $this->json( [ $data = json_decode( $data, true );
'message' => 'answer ' . $voteInfo[ 'value' ] . ' is not allowed. should be yes, maybe, or no.', // $data = $data['data'];
'vote_stack' => $stack,
], $owner = new Owner();
404 ); $owner->addPoll($poll);
$newStack = new StackOfVotes();
$newStack
->setPseudo( $data[ 'pseudo' ] )
->setOwner($owner );
// TODO manage new comment
$emChoice = $choice_repository;
foreach ( $data[ 'votes' ] as $vote ) {
$newVote = new Vote();
$newVote->setPoll($poll);
$newStack->addVote( $newVote );
$choiceFound = $emChoice->find( $vote[ 'choice_id' ] );
if ( $choiceFound ) {
$choiceFound->addVote( $newVote );
$newVote->setStacksOfVotes( $newStack )
->setChoice( $choiceFound )
->setValue( $vote[ 'value' ] );
$em->persist( $choiceFound );
} else {
throw new NotFoundHttpException( 'no choice of id' . $vote[ 'choice_id' ] );
}
$poll->addVote($newVote);
$em->persist( $newVote );
} }
$vote = new Vote(); $newStack
$foundChoice = $emChoice->find( $voteInfo[ 'choice_id' ] ); ->setPoll( $poll );
if ( ! $foundChoice ) { $em->persist( $newStack );
return $this->json( [ $em->persist( $poll );
'message' => 'choice ' . $voteInfo[ 'choice_id' ] . ' was not found',
'vote_stack' => $stack,
],
404 );
}
$vote->setPoll( $poll )
->setChoice( $foundChoice )
->setValue( $voteInfo[ 'value' ] );
$vote->setPoll( $poll );
$stack->addVote( $vote );
$poll->addVote( $vote );
$em->persist( $vote );
$em->persist( $foundChoice );
}
// find poll from choices
$poll->addStackOfVote( $stack );
$em->persist( $stack );
$em->persist( $poll );
$em->flush();
$precision = '';
if ( $existingOwner ) {
$precision = ' from an existing owner : ' . $foundOwner->getEmail();
}
$stacks = $poll->getStacksOfVotes();
if ( $poll->getMailOnVote() ) {
$this->sendVoteNotificationAction( $stack->getOwner(), $stack );
}
$returnedVoteStack = $stack;
$jsonResponse = $serializer->serialize( $returnedVoteStack, 'json' );
$response = new Response( $jsonResponse );
$response->headers->set( 'Content-Type', 'application/json' );
$response->setStatusCode( 200 );
return $response;
}
/**
* update vote stack
* @Patch(
* path = "/vote-stack/{id}/token/{modifierToken}",
* name = "update_vote_stack",
* requirements = { "id"="\d+"}
* )
*
* @param SerializerInterface $serializer
* @param StackOfVotes $id
* @param $modifierToken
* @param Request $request
*
* @return JsonResponse|Response
*/
public
function updateVoteStackAction(
SerializerInterface $serializer,
StackOfVotes $id,
$modifierToken,
Request $request
) {
$voteStack = $id;
if ( ! $voteStack ) {
return $this->json( [ 'message' => 'vote stack not found' ], 404 );
}
$poll = $voteStack->getPoll();
// if only self users are allowed to modify a vote, check it
if ( ! $modifierToken || $voteStack->getOwner()->getModifierToken() !== $modifierToken ) {
return $this->json( [ 'message' => 'your token does not allow you to modify this vote ' ],
403 );
}
// everything is ok, we can update all the votes of the vote stack
//TODO
// match votes and choices
// update answers
// save evrything
$jsonResponse = $serializer->serialize( [
'message' => 'ok',
'modifier_token' => $voteStack->getOwner()->getModifierToken(),
'vote_stack' => $voteStack,
],
'json' );
$response = new Response( $jsonResponse );
$response->headers->set( 'Content-Type', 'application/json' );
$response->setStatusCode( 200 );
return $response;
}
/**
* @Delete(
* path = "/poll/{id}/votes/{accessToken}",
* name = "poll_votes_delete",
* requirements = {"accessToken"="\w+", "poll_id"="\d+"}
* )
* @return JsonResponse
*/
public
function deletePollVotesAction(
Poll $poll,
$accessToken
) {
if ( $accessToken == $poll->getAdminKey() ) {
$em = $this->getDoctrine()->getManager();
$length = count( $poll->getVotes() );
$em->remove( $poll->getVotes() );
$em->flush(); $em->flush();
return $this->json( [ return $this->json( [
'message' => 'boom! les ' . $length . ' votes du sondage ont été supprimés', 'data' => $data,
] );
// $emOwner = $em->getRepository( Owner::class );
// $emChoice = $em->getRepository( Choice::class );
// $existingOwner = false;
// $foundOwner = $emOwner->findOneByEmail( trim( $data[ 'email' ] ) );
// manage existing or new Owner
// if ( ! $foundOwner ) {
// $foundOwner = new Owner();
// $foundOwner
// ->setEmail( $data[ 'email' ] )
// ->setPseudo( $data[ 'pseudo' ] );
// } else {
// $existingOwner = true;
// }
// TODO anti flood
// $foundOwner
// ->setModifierToken( $poll->generateRandomKey() );
// $stack = new StackOfVotes();
// $stack
// ->setOwner( $foundOwner )
// ->setIp( $_SERVER[ 'REMOTE_ADDR' ] )
// ->setPseudo( $data[ 'pseudo' ] )
// ->setPoll( $custom_url );
// foreach ( $data[ 'votes' ] as $voteInfo ) {
//
// if ( ! isset( $voteInfo[ 'value' ] ) ) {
// continue;
// }
// $allowedValuesToAnswer = [ 'yes', 'maybe', 'no' ];
//
// if ( ! in_array( $voteInfo[ 'value' ], $allowedValuesToAnswer ) ) {
// return $this->json( [
// 'message' => 'answer ' . $voteInfo[ 'value' ] . ' is not allowed. should be yes, maybe, or no.',
// 'vote_stack' => $stack,
// ],
// 404 );
// }
// $vote = new Vote();
// $foundChoice = $emChoice->find( $voteInfo[ 'choice_id' ] );
// if ( ! $foundChoice ) {
// return $this->json( [
// 'message' => 'choice ' . $voteInfo[ 'choice_id' ] . ' was not found',
// 'vote_stack' => $stack,
// ],
// 404 );
// }
// $vote->setPoll( $poll )
// ->setChoice( $foundChoice )
// ->setValue( $voteInfo[ 'value' ] );
// $vote->setPoll( $poll );
// $stack->addVote( $vote );
// $poll->addVote( $vote );
// $em->persist( $vote );
// $em->persist( $foundChoice );
// }
//
// // find poll from choices
// $poll->addStackOfVote( $stack );
// $em->persist( $stack );
// $em->persist( $poll );
// $em->flush();
// $precision = '';
// if ( $existingOwner ) {
// $precision = ' from an existing owner : ' . $foundOwner->getEmail();
// }
//
// if ( $poll->getMailOnVote() ) {
// $this->sendVoteNotificationAction( $stack->getOwner(), $stack );
// }
//
// $returnedVoteStack = $stack;
//
// $jsonResponse = $serializer->serialize( $returnedVoteStack, 'json' );
//
// $response = new Response( $jsonResponse );
// $response->headers->set( 'Content-Type', 'application/json' );
// $response->setStatusCode( 200 );
//
// return $response;
}
/**
* update vote stack
* @Patch(
* path = "/vote-stack/{id}/token/{modifierToken}",
* name = "update_vote_stack",
* requirements = { "id"="\d+"}
* )
*
* @param SerializerInterface $serializer
* @param StackOfVotes $id
* @param $modifierToken
* @param Request $request
*
* @return JsonResponse|Response
*/
public
function updateVoteStackAction(
SerializerInterface $serializer,
StackOfVotes $id,
$modifierToken,
Request $request
) {
$voteStack = $id;
if ( ! $voteStack ) {
return $this->json( [ 'message' => 'vote stack not found' ], 404 );
}
$poll = $voteStack->getPoll();
// if only self users are allowed to modify a vote, check it
if ( ! $modifierToken || $voteStack->getOwner()->getModifierToken() !== $modifierToken ) {
return $this->json( [ 'message' => 'your token does not allow you to modify this vote ' ],
403 );
}
// everything is ok, we can update all the votes of the vote stack
//TODO
// match votes and choices
// update answers
// save evrything
$jsonResponse = $serializer->serialize( [
'message' => 'ok',
'modifier_token' => $voteStack->getOwner()->getModifierToken(),
'vote_stack' => $voteStack,
], ],
200 ); 'json' );
} else {
return $this->json( [ $response = new Response( $jsonResponse );
'message' => 'le token d\'autorisation est invalide, vous ne pouvez pas modifier ce sondage', $response->headers->set( 'Content-Type', 'application/json' );
], $response->setStatusCode( 200 );
403 );
return $response;
}
/**
* @Delete(
* path = "/poll/{id}/votes/{accessToken}",
* name = "poll_votes_delete",
* requirements = {"accessToken"="\w+", "poll_id"="\d+"}
* )
* @return JsonResponse
*/
public
function deletePollVotesAction(
Poll $poll,
$accessToken
) {
if ( $accessToken == $poll->getAdminKey() ) {
$em = $this->getDoctrine()->getManager();
$length = count( $poll->getVotes() );
$em->remove( $poll->getVotes() );
$em->flush();
return $this->json( [
'message' => 'boom! les ' . $length . ' votes du sondage ont été supprimés',
],
200 );
} else {
return $this->json( [
'message' => 'le token d\'autorisation est invalide, vous ne pouvez pas modifier ce sondage',
],
403 );
}
} }
} }
}

View File

@ -21,13 +21,13 @@ class Owner {
* @Serializer\Type("string") * @Serializer\Type("string")
* @Serializer\Expose() * @Serializer\Expose()
*/ */
public $pseudo; public $pseudo = 'anonyme';
/** /**
* @ORM\Column(type="string", length=255) * @ORM\Column(type="string", length=255)
* @Serializer\Type("string") * @Serializer\Type("string")
* @Serializer\Expose() * @Serializer\Expose()
*/ */
public $email; public $email = "anonyme@anonyme.com";
/** /**
* @ORM\Id() * @ORM\Id()
* @ORM\GeneratedValue() * @ORM\GeneratedValue()

View File

@ -108,15 +108,6 @@ class Vote {
return $this; return $this;
} }
public function getCreationDate(): ?DateTimeInterface {
return $this->creationDate;
}
public function setCreationDate( DateTimeInterface $creationDate ): self {
$this->creationDate = $creationDate;
return $this;
}
public function getStacksOfVotes(): ?StackOfVotes { public function getStacksOfVotes(): ?StackOfVotes {
return $this->stacksOfVotes; return $this->stacksOfVotes;

View File

@ -4,7 +4,7 @@ namespace App\Repository;
use App\Entity\Choice; use App\Entity\Choice;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**
* @method Choice|null find( $id, $lockMode = null, $lockVersion = null ) * @method Choice|null find( $id, $lockMode = null, $lockVersion = null )
@ -17,32 +17,4 @@ class ChoiceRepository extends ServiceEntityRepository {
parent::__construct( $registry, Choice::class ); parent::__construct( $registry, Choice::class );
} }
// /**
// * @return Choice[] Returns an array of Choice objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->orderBy('c.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Choice
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
} }

View File

@ -4,7 +4,7 @@ namespace App\Repository;
use App\Entity\Comment; use App\Entity\Comment;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**
* @method Comment|null find( $id, $lockMode = null, $lockVersion = null ) * @method Comment|null find( $id, $lockMode = null, $lockVersion = null )

View File

@ -4,7 +4,7 @@ namespace App\Repository;
use App\Entity\Owner; use App\Entity\Owner;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**
* @method Owner|null find( $id, $lockMode = null, $lockVersion = null ) * @method Owner|null find( $id, $lockMode = null, $lockVersion = null )

View File

@ -4,7 +4,7 @@ namespace App\Repository;
use App\Entity\StackOfVotes; use App\Entity\StackOfVotes;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**
* @method StackOfVotes|null find( $id, $lockMode = null, $lockVersion = null ) * @method StackOfVotes|null find( $id, $lockMode = null, $lockVersion = null )

View File

@ -4,7 +4,7 @@ namespace App\Repository;
use App\Entity\Vote; use App\Entity\Vote;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**
* @method Vote|null find( $id, $lockMode = null, $lockVersion = null ) * @method Vote|null find( $id, $lockMode = null, $lockVersion = null )