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

get protected pass route works

This commit is contained in:
Tykayn 2021-04-21 11:44:06 +02:00 committed by tykayn
parent 1570a1cf0f
commit 2d2607d30b
3 changed files with 160 additions and 155 deletions

View File

@ -135,7 +135,6 @@ class PollController extends EmailsController {
* @Get( * @Get(
* path = "/{customUrl}/pass/{md5}", * path = "/{customUrl}/pass/{md5}",
* name = "get_protected_poll", * name = "get_protected_poll",
* requirements = {"customUrl"="\w+"}
* ) * )
* *
* @param SerializerInterface $serializer * @param SerializerInterface $serializer
@ -143,12 +142,12 @@ class PollController extends EmailsController {
* *
* @return JsonResponse|Response * @return JsonResponse|Response
*/ */
function getProtectedPoll($id,$md5, SerializerInterface $serializer){ function getProtectedPoll($customUrl,$md5, SerializerInterface $serializer){
$repository = $this->getDoctrine()->getRepository( Poll::class ); $repository = $this->getDoctrine()->getRepository( Poll::class );
$poll = $repository->findOneByCustomUrl( $id ); $poll = $repository->findOneByCustomUrl( $customUrl );
if ( ! $poll ) { if ( ! $poll ) {
return $this->notFoundPoll($id); return $this->notFoundPoll($customUrl);
} }
if ( $poll->getPassword() === $md5 ) { if ( $poll->getPassword() === $md5 ) {

View File

@ -10,8 +10,7 @@ use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
class CommentFixtures extends Fixture implements DependentFixtureInterface { class CommentFixtures extends Fixture implements DependentFixtureInterface {
public function getDependencies() public function getDependencies() {
{
return [ return [
AppPollFixtures::class, AppPollFixtures::class,
]; ];
@ -28,66 +27,63 @@ class CommentFixtures extends Fixture implements DependentFixtureInterface {
->setPseudo( 'Wulfila' ); ->setPseudo( 'Wulfila' );
// comment on "citron ou orange" // comment on "citron ou orange"
$pollCitronOrange = $this->getReference(AppPollFixtures::POLL_FIXTURE_ONE); $pollCitronOrange = $this->getReference( AppPollFixtures::POLL_FIXTURE_ONE );
if ( $pollCitronOrange ) { $comment = new Comment();
$comment->setOwner( $commenterMan )
->setPseudo( 'the indécis people' )
->setText( 'quelle indécision wololo! finalement citron. heu non orange. AAAAh!' );
$pollCitronOrange->addComment( $comment );
$manager->persist( $comment );
$manager->persist( $pollCitronOrange );
$manager->persist( $commenterMan );
$manager->flush();
$comment = new Comment(); // comment on "démo sondage de texte avec deux commentaires"
$comment->setOwner( $commenterMan ) // $poll = $emPoll->find( 2 );
->setPseudo( 'the indécis people' ) // $comment = new Comment();
->setText( 'quelle indécision wololo! finalement citron. heu non orange. AAAAh!' ); // $comment->setOwner( $commenterMan2 )
$pollCitronOrange->addComment( $comment ); // ->setPseudo( 'The Hayroule king' )
$manager->persist( $comment ); // ->setText( 'il est écrit Squalala.' );
$manager->persist( $pollCitronOrange ); // $pollCitronOrange->addComment( $comment );
$manager->persist( $commenterMan ); // $manager->persist( $comment );
$manager->flush(); // $manager->persist( $poll );
// $manager->persist( $commenterMan2 );
// $manager->flush();
//
// $comment = new Comment();
// $comment->setOwner( $commenterMan )
// ->setPseudo( 'The Hayroule king' )
// ->setText( "Zelda. Orange." );
// $pollCitronOrange->addComment( $comment );
// $manager->persist( $comment );
// $manager->persist( $poll );
// $manager->persist( $commenterMan );
// $manager->flush();
//
//
// // comment on "c'est pour aujourdhui ou pour demain"
// $poll = $emPoll->find( 3 );
// $comment = new Comment();
// $comment->setOwner( $commenterMan )
// ->setPseudo( 'The Hayroule king' )
// ->setText( "va pour demain" );
// $pollCitronOrange->addComment( $comment );
// $manager->persist( $comment );
// $manager->persist( $poll );
// $manager->persist( $commenterMan );
// $manager->flush();
//
// // comment on "dessin animé préféré"
// $poll = $emPoll->find( 4 );
// $comment = new Comment();
// $comment->setOwner( $commenterMan2 )
// ->setPseudo( 'The Hayroule king' )
// ->setText( "Ceci est un commentaire de fixture créé avec le CipherBliss poweur." );
// $pollCitronOrange->addComment( $comment );
// $manager->persist( $comment );
// $manager->persist( $poll );
// $manager->persist( $commenterMan2 );
// comment on "démo sondage de texte avec deux commentaires"
$poll = $emPoll->find( 2 );
$comment = new Comment();
$comment->setOwner( $commenterMan2 )
->setPseudo( 'The Hayroule king' )
->setText( 'il est écrit Squalala.' );
$pollCitronOrange->addComment( $comment );
$manager->persist( $comment );
$manager->persist( $poll );
$manager->persist( $commenterMan2 );
$manager->flush();
$comment = new Comment();
$comment->setOwner( $commenterMan )
->setPseudo( 'The Hayroule king' )
->setText( "Zelda. Orange." );
$pollCitronOrange->addComment( $comment );
$manager->persist( $comment );
$manager->persist( $poll );
$manager->persist( $commenterMan );
$manager->flush();
// comment on "c'est pour aujourdhui ou pour demain"
$poll = $emPoll->find( 3 );
$comment = new Comment();
$comment->setOwner( $commenterMan )
->setPseudo( 'The Hayroule king' )
->setText( "va pour demain" );
$pollCitronOrange->addComment( $comment );
$manager->persist( $comment );
$manager->persist( $poll );
$manager->persist( $commenterMan );
$manager->flush();
// comment on "dessin animé préféré"
$poll = $emPoll->find( 4 );
$comment = new Comment();
$comment->setOwner( $commenterMan2 )
->setPseudo( 'The Hayroule king' )
->setText( "Ceci est un commentaire de fixture créé avec le CipherBliss poweur." );
$pollCitronOrange->addComment( $comment );
$manager->persist( $comment );
$manager->persist( $poll );
$manager->persist( $commenterMan2 );
}
$manager->flush(); $manager->flush();
} }
} }

View File

@ -7,11 +7,18 @@ use App\Entity\Poll;
use App\Entity\StackOfVotes; use App\Entity\StackOfVotes;
use App\Entity\Vote; use App\Entity\Vote;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
class VotesStacksFixtures extends Fixture { class VotesStacksFixtures extends Fixture implements DependentFixtureInterface {
public function getDependencies()
{
return [
AppPollFixtures::class,
];
}
public function load( ObjectManager $manager ) { public function load( ObjectManager $manager ) {
$emPoll = $manager->getRepository( Poll::class );
$people1 = new Owner(); $people1 = new Owner();
$people1->setEmail( 'tktest_nikolas_edison@tktest.com' ) $people1->setEmail( 'tktest_nikolas_edison@tktest.com' )
@ -24,124 +31,127 @@ class VotesStacksFixtures extends Fixture {
->setPseudo( 'Billie Jean' ); ->setPseudo( 'Billie Jean' );
// "citron ou orange" // "citron ou orange"
$poll = $emPoll->find( 1 ); // add vote stacks on "citron ou orange"
$pollCitronOrange = $this->getReference(AppPollFixtures::POLL_FIXTURE_ONE);
$stack1 = new StackOfVotes(); $stack1 = new StackOfVotes();
$stack1 $stack1
->setPoll( $poll ) ->setPoll( $pollCitronOrange )
->setOwner( $people1 ); ->setOwner( $people1 );
$voteA = new Vote(); $voteA = new Vote();
$voteA $voteA
->setPoll( $poll ) ->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack1 ) ->setStacksOfVotes( $stack1 )
->setValue( "yes" ) ->setValue( "yes" )
->setChoice( $poll->getChoices()[ 0 ] ); ->setChoice( $pollCitronOrange->getChoices()[ 0 ] );
$voteB = new Vote(); $voteB = new Vote();
$voteB $voteB
->setPoll( $poll ) ->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack1 ) ->setStacksOfVotes( $stack1 )
->setValue( "maybe" ) ->setValue( "maybe" )
->setChoice( $poll->getChoices()[ 1 ] ); ->setChoice( $pollCitronOrange->getChoices()[ 1 ] );
$poll->addStackOfVote( $stack1 ); $pollCitronOrange->addStackOfVote( $stack1 );
$manager->persist( $poll ); $manager->persist( $pollCitronOrange );
$manager->persist( $people1 ); $manager->persist( $people1 );
$manager->persist( $stack1 ); $manager->persist( $stack1 );
$stack2 = new StackOfVotes(); $stack2 = new StackOfVotes();
$stack2 $stack2
->setPoll( $poll ) ->setPoll( $pollCitronOrange )
->setOwner( $people2 ); ->setOwner( $people2 );
$voteA = new Vote(); $voteA = new Vote();
$voteA $voteA
->setPoll( $poll ) ->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack2 ) ->setStacksOfVotes( $stack2 )
->setValue( "no" ) ->setValue( "no" )
->setChoice( $poll->getChoices()[ 0 ] ); ->setChoice( $pollCitronOrange->getChoices()[ 0 ] );
$voteB = new Vote(); $voteB = new Vote();
$voteB $voteB
->setPoll( $poll ) ->setPoll( $pollCitronOrange )
->setStacksOfVotes( $stack2 ) ->setStacksOfVotes( $stack2 )
->setValue( "yes" ) ->setValue( "yes" )
->setChoice( $poll->getChoices()[ 1 ] ); ->setChoice( $pollCitronOrange->getChoices()[ 1 ] );
$poll->addStackOfVote( $stack2 ); $pollCitronOrange->addStackOfVote( $stack2 );
$manager->persist( $poll ); $manager->persist( $pollCitronOrange );
$manager->persist( $stack2 ); $manager->persist( $stack2 );
$manager->persist( $people2 ); $manager->persist( $people2 );
// $stack1 = new StackOfVotes();
// $stack1
// ->setPoll( $pollCitronOrange )
// ->setOwner( $people1 );
// $voteA = new Vote();
// $voteA
// ->setPoll( $pollCitronOrange )
// ->setStacksOfVotes( $stack1 )
// ->setValue( "maybe" )
// ->setChoice( $pollCitronOrange->getChoices()[ 2 ] );
// $voteB = new Vote();
// $voteB
// ->setPoll( $pollCitronOrange )
// ->setStacksOfVotes( $stack1 )
// ->setValue( "maybe" )
// ->setChoice( $pollCitronOrange->getChoices()[ 4 ] );
// $pollCitronOrange->addStackOfVote( $stack1 );
// $manager->persist( $pollCitronOrange );
// $manager->persist( $people1 );
// $manager->persist( $stack1 );
//
//
// $stack2 = new StackOfVotes();
// $stack2
// ->setPoll( $pollCitronOrange )
// ->setOwner( $people2 );
// $voteA = new Vote();
// $voteA
// ->setPoll( $pollCitronOrange )
// ->setStacksOfVotes( $stack2 )
// ->setValue( "maybe" )
// ->setChoice( $pollCitronOrange->getChoices()[ 3 ] );
// $voteB = new Vote();
// $voteB
// ->setPoll( $pollCitronOrange )
// ->setStacksOfVotes( $stack2 )
// ->setValue( "yes" )
// ->setChoice( $pollCitronOrange->getChoices()[ 5 ] );
// $pollCitronOrange->addStackOfVote( $stack2 );
// $manager->persist( $pollCitronOrange );
// $manager->persist( $people2 );
// $manager->persist( $stack2 );
//
//
// $stack3 = new StackOfVotes();
// $stack3
// ->setPoll( $pollCitronOrange )
// ->setOwner( $people3 );
// $voteA = new Vote();
// $voteA
// ->setPoll( $pollCitronOrange )
// ->setStacksOfVotes( $stack3 )
// ->setValue( "yes" )
// ->setChoice( $pollCitronOrange->getChoices()[ 1 ] );
// $voteB = new Vote();
// $voteB
// ->setPoll( $pollCitronOrange )
// ->setStacksOfVotes( $stack3 )
// ->setValue( "yes" )
// ->setChoice( $pollCitronOrange->getChoices()[ 3 ] );
// $pollCitronOrange->addStackOfVote( $stack3 );
// $manager->persist( $pollCitronOrange );
// $manager->persist( $people3 );
// $manager->persist( $stack3 );
// comment on "démo sondage de texte avec deux commentaires" // comment on "démo sondage de texte avec deux commentaires"
$poll = $emPoll->find( 2 ); // $poll = $emPoll->find( 2 );
//
//
// comment on "c'est pour aujourdhui ou pour demain" // // comment on "c'est pour aujourdhui ou pour demain"
$poll = $emPoll->find( 3 ); // $poll = $emPoll->find( 3 );
//
//
// comment on "dessin animé préféré" // // comment on "dessin animé préféré"
$poll = $emPoll->find( 4 ); // $poll = $emPoll->find( 4 );
$stack1 = new StackOfVotes();
$stack1
->setPoll( $poll )
->setOwner( $people1 );
$voteA = new Vote();
$voteA
->setPoll( $poll )
->setStacksOfVotes( $stack1 )
->setValue( "maybe" )
->setChoice( $poll->getChoices()[ 2 ] );
$voteB = new Vote();
$voteB
->setPoll( $poll )
->setStacksOfVotes( $stack1 )
->setValue( "maybe" )
->setChoice( $poll->getChoices()[ 4 ] );
$poll->addStackOfVote( $stack1 );
$manager->persist( $poll );
$manager->persist( $people1 );
$manager->persist( $stack1 );
$stack2 = new StackOfVotes();
$stack2
->setPoll( $poll )
->setOwner( $people2 );
$voteA = new Vote();
$voteA
->setPoll( $poll )
->setStacksOfVotes( $stack2 )
->setValue( "maybe" )
->setChoice( $poll->getChoices()[ 3 ] );
$voteB = new Vote();
$voteB
->setPoll( $poll )
->setStacksOfVotes( $stack2 )
->setValue( "yes" )
->setChoice( $poll->getChoices()[ 5 ] );
$poll->addStackOfVote( $stack2 );
$manager->persist( $poll );
$manager->persist( $people2 );
$manager->persist( $stack2 );
$stack3 = new StackOfVotes();
$stack3
->setPoll( $poll )
->setOwner( $people3 );
$voteA = new Vote();
$voteA
->setPoll( $poll )
->setStacksOfVotes( $stack3 )
->setValue( "yes" )
->setChoice( $poll->getChoices()[ 1 ] );
$voteB = new Vote();
$voteB
->setPoll( $poll )
->setStacksOfVotes( $stack3 )
->setValue( "yes" )
->setChoice( $poll->getChoices()[ 3 ] );
$poll->addStackOfVote( $stack3 );
$manager->persist( $poll );
$manager->persist( $people3 );
$manager->persist( $stack3 );
$manager->flush(); $manager->flush();
} }