Revert "add graphql bundle"
rearrange controllers for api and no api
This reverts commit 8fbd5462
This commit is contained in:
parent
21c594a2fd
commit
aab2d74b19
|
@ -11,7 +11,7 @@ use FOS\RestBundle\Controller\Annotations\Route;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/admin",name="admin_homepage")
|
* @Route("/admin",name="admin_homepage")
|
||||||
*/
|
*/
|
||||||
class AdminController extends FramadateController {
|
class AdminController extends EmailsController {
|
||||||
/**
|
/**
|
||||||
* @Get(path ="/",
|
* @Get(path ="/",
|
||||||
* name = "_get_default")
|
* name = "_get_default")
|
||||||
|
|
|
@ -17,7 +17,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/",name="home_")
|
* @Route("/",name="home_")
|
||||||
*/
|
*/
|
||||||
class DefaultController extends FramadateController {
|
class DefaultController extends EmailsController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Get(path ="/",
|
* @Get(path ="/",
|
||||||
|
@ -27,7 +27,7 @@ class DefaultController extends FramadateController {
|
||||||
|
|
||||||
$polls = $this->getDoctrine()->getRepository( Poll::class )->findAll();
|
$polls = $this->getDoctrine()->getRepository( Poll::class )->findAll();
|
||||||
|
|
||||||
return $this->render( 'pages/home.html.twig',[ ]);
|
return $this->render( 'pages/home.html.twig', [] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
/**
|
/**
|
||||||
* sending emails controller
|
* sending emails controller
|
||||||
*
|
*
|
||||||
* Class FramadateController
|
* Class EmailsController
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
*/
|
*/
|
||||||
class FramadateController extends AbstractController {
|
class EmailsController extends AbstractController {
|
||||||
|
|
||||||
private $mail_service;
|
private $mail_service;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class FramadateController extends AbstractController {
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
'owner' => $owner,
|
'owner' => $owner,
|
||||||
'title' => 'Framadate | Mes sondages',
|
'title' => $this->getParameter( 'WEBSITE_NAME' ) . ' | Mes sondages',
|
||||||
'email_template' => 'emails/owner-list.html.twig',
|
'email_template' => 'emails/owner-list.html.twig',
|
||||||
];
|
];
|
||||||
$this->sendMailWithVars( $config );
|
$this->sendMailWithVars( $config );
|
|
@ -21,7 +21,7 @@ use App\Entity\Poll;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/migration-from-v1",name="admin_homepage")
|
* @Route("/migration-from-v1",name="admin_homepage")
|
||||||
*/
|
*/
|
||||||
class MigrationController extends FramadateController {
|
class MigrationController extends EmailsController {
|
||||||
/**
|
/**
|
||||||
* @Get(path ="/{unique_key}",
|
* @Get(path ="/{unique_key}",
|
||||||
* name = "_migrate_from_v1")
|
* name = "_migrate_from_v1")
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/user",name="user_homepage")
|
* @Route("/user",name="user_homepage")
|
||||||
*/
|
*/
|
||||||
class OwnerController extends FramadateController {
|
class OwnerController extends EmailsController {
|
||||||
/**
|
/**
|
||||||
* @Get(path ="/",
|
* @Get(path ="/",
|
||||||
* name = "get_default")
|
* name = "get_default")
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller\api;
|
||||||
|
|
||||||
|
use App\Controller\EmailsController;
|
||||||
use App\Entity\Comment;
|
use App\Entity\Comment;
|
||||||
use App\Entity\Owner;
|
use App\Entity\Owner;
|
||||||
use App\Entity\Poll;
|
use App\Entity\Poll;
|
||||||
|
@ -21,7 +22,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/api/v1",name="api_")
|
* @Route("/api/v1",name="api_")
|
||||||
*/
|
*/
|
||||||
class CommentController extends FramadateController {
|
class CommentController extends EmailsController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Get(
|
* @Get(
|
||||||
|
@ -32,18 +33,18 @@ class CommentController extends FramadateController {
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
function getPollCommentsAction(
|
function getPollCommentsAction(
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
Poll $poll
|
Poll $poll
|
||||||
) {
|
) {
|
||||||
$jsonResponse = $serializer->serialize([
|
$jsonResponse = $serializer->serialize([
|
||||||
'message' => 'here are your comments of the poll',
|
'message' => 'here are your comments of the poll',
|
||||||
'data' => $poll->getComments()], 'json');
|
'data' => $poll->getComments()], 'json');
|
||||||
|
|
||||||
$response = new Response($jsonResponse);
|
$response = new Response($jsonResponse);
|
||||||
$response->headers->set('Content-Type', 'application/json');
|
$response->headers->set('Content-Type', 'application/json');
|
||||||
$response->setStatusCode(200);
|
$response->setStatusCode(200);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +81,8 @@ class CommentController extends FramadateController {
|
||||||
if ( ! $foundOwner ) {
|
if ( ! $foundOwner ) {
|
||||||
$foundOwner = new Owner();
|
$foundOwner = new Owner();
|
||||||
$foundOwner->setPseudo( $data[ 'email' ] )
|
$foundOwner->setPseudo( $data[ 'email' ] )
|
||||||
->setEmail( $data[ 'email' ] )
|
->setEmail( $data[ 'email' ] )
|
||||||
->setModifierToken( uniqid( '', true ) );
|
->setModifierToken( uniqid( '', true ) );
|
||||||
}
|
}
|
||||||
// anti flood
|
// anti flood
|
||||||
$seconds_limit_lastpost = 5;
|
$seconds_limit_lastpost = 5;
|
||||||
|
@ -117,8 +118,8 @@ class CommentController extends FramadateController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$comment->setOwner( $foundOwner )
|
$comment->setOwner( $foundOwner )
|
||||||
->setCreatedAt( new DateTime() )
|
->setCreatedAt( new DateTime() )
|
||||||
->setPoll( $poll );
|
->setPoll( $poll );
|
||||||
$foundOwner->addComment( $comment );
|
$foundOwner->addComment( $comment );
|
||||||
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Controller\api;
|
namespace App\Controller\api;
|
||||||
|
|
||||||
use App\Controller\FramadateController;
|
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;
|
||||||
|
@ -27,15 +27,15 @@ use FOS\RestBundle\Controller\Annotations\Route;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/api/v1/poll",name="api_")
|
* @Route("/api/v1/poll",name="api_")
|
||||||
*/
|
*/
|
||||||
class PollController extends FramadateController {
|
class PollController extends EmailsController {
|
||||||
/**
|
/**
|
||||||
* @Get(
|
* @Get(
|
||||||
* path = "/",
|
* path = "/",
|
||||||
* name = "get_all_polls"
|
* name = "get_all_polls"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function getAllPollsAction(PollRepository $pollRepository): Response {
|
public function getAllPollsAction( PollRepository $pollRepository ): Response {
|
||||||
$data = $pollRepository->findAll();
|
$data = $pollRepository->findAll();
|
||||||
|
|
||||||
|
|
||||||
$polls = $data;
|
$polls = $data;
|
||||||
|
@ -76,9 +76,9 @@ class PollController extends FramadateController {
|
||||||
/**
|
/**
|
||||||
* get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
|
* get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
|
||||||
* @Get(
|
* @Get(
|
||||||
* path = "/{id}",
|
* path = "/{customUrl}",
|
||||||
* name = "get_poll",
|
* name = "get_poll",
|
||||||
* requirements = {"id"="\w+"}
|
* requirements = {"customUrl"="\w+"}
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
* @param SerializerInterface $serializer
|
||||||
|
@ -88,14 +88,14 @@ class PollController extends FramadateController {
|
||||||
*/
|
*/
|
||||||
public function getPollConfig(
|
public function getPollConfig(
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
$id,
|
$customUrl,
|
||||||
Request $request
|
Request $request
|
||||||
): Response {
|
): Response {
|
||||||
$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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$comments = $poll->getComments();
|
$comments = $poll->getComments();
|
||||||
|
@ -134,9 +134,9 @@ class PollController extends FramadateController {
|
||||||
/**
|
/**
|
||||||
* get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
|
* get a poll config by its custom URL, we do not want polls to be reachable by their numeric id
|
||||||
* @Get(
|
* @Get(
|
||||||
* path = "/{id}/pass/{md5}",
|
* path = "/{customUrl}/pass/{md5}",
|
||||||
* name = "get_protected_poll",
|
* name = "get_protected_poll",
|
||||||
* requirements = {"id"="\w+"}
|
* requirements = {"customUrl"="\w+"}
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* @param SerializerInterface $serializer
|
* @param SerializerInterface $serializer
|
||||||
|
@ -180,7 +180,7 @@ class PollController extends FramadateController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Put(
|
* @Put(
|
||||||
* path = "/{id}/{token}",
|
* path = "/{customUrl}/{token}",
|
||||||
* name = "update_poll",
|
* name = "update_poll",
|
||||||
* requirements = {"content"="\w+", "poll_id"="\d+"}
|
* requirements = {"content"="\w+", "poll_id"="\d+"}
|
||||||
* )
|
* )
|
||||||
|
@ -363,7 +363,7 @@ class PollController extends FramadateController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Delete(
|
* @Delete(
|
||||||
* path = "/{id}",
|
* path = "/{customUrl}",
|
||||||
* name = "poll_delete",
|
* name = "poll_delete",
|
||||||
* requirements = {"accessToken"="\w+", "poll_id"="\d+"}
|
* requirements = {"accessToken"="\w+", "poll_id"="\d+"}
|
||||||
* )
|
* )
|
||||||
|
@ -397,13 +397,13 @@ class PollController extends FramadateController {
|
||||||
/**
|
/**
|
||||||
* Checks if a slug is already taken by a poll
|
* Checks if a slug is already taken by a poll
|
||||||
* @Get(
|
* @Get(
|
||||||
* path = "/slug/{slug}",
|
* path = "/slug/{customUrl}",
|
||||||
* name = "check_slug_is_unique",
|
* name = "check_slug_is_unique",
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function checkSlugIsUniqueAction( string $slug ) {
|
public function checkSlugIsUniqueAction( string $customUrl ) {
|
||||||
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
|
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
|
||||||
$found = $emPoll->findOneByCustomUrl( $slug );
|
$found = $emPoll->findOneByCustomUrl( $customUrl );
|
||||||
$elaborated_message_version = false;
|
$elaborated_message_version = false;
|
||||||
|
|
||||||
if ( $found ) {
|
if ( $found ) {
|
||||||
|
@ -416,7 +416,7 @@ class PollController extends FramadateController {
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
'message' => ' NO, this slug is already taken on this Framadate instance ',
|
'message' => ' NO, this slug is already taken on this Framadate instance ',
|
||||||
'data' => [
|
'data' => [
|
||||||
'slug' => $slug,
|
'slug' => $customUrl,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
204 );
|
204 );
|
||||||
|
@ -429,7 +429,7 @@ class PollController extends FramadateController {
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
'message' => ' yes this slug is available on this Framadate instance ',
|
'message' => ' yes this slug is available on this Framadate instance ',
|
||||||
'data' => [
|
'data' => [
|
||||||
'slug' => $slug,
|
'slug' => $customUrl,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
404 );
|
404 );
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller\api;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -21,25 +22,25 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
* @package App\Controller
|
* @package App\Controller
|
||||||
* @Route("/api/v1",name="api_")
|
* @Route("/api/v1",name="api_")
|
||||||
*/
|
*/
|
||||||
class VoteController extends FramadateController {
|
class VoteController extends EmailsController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add a vote stack on a poll
|
* add a vote stack on a poll
|
||||||
* @Post(
|
* @Post(
|
||||||
* path = "/poll/{id}/answer",
|
* path = "/poll/{id}/answer",
|
||||||
* name = "new_vote_stack",
|
* name = "new_vote_stack",
|
||||||
* requirements = {"content"="\w+", "poll_id"="\d+"}
|
* requirements = {"content"="\w+", "poll_id"="\d+"}
|
||||||
* )
|
* )
|
||||||
* @param SerializerInterface $serializer
|
* @param SerializerInterface $serializer
|
||||||
* @param Poll $poll
|
* @param Poll $poll
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return JsonResponse|Response
|
* @return JsonResponse|Response
|
||||||
*/
|
*/
|
||||||
public function newVoteStackAction(
|
public function newVoteStackAction(
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
Poll $poll,
|
Poll $poll,
|
||||||
Request $request
|
Request $request
|
||||||
) {
|
) {
|
||||||
if ( ! $poll ) {
|
if ( ! $poll ) {
|
||||||
return $this->json( [ 'message' => 'poll not found' ], 404 );
|
return $this->json( [ 'message' => 'poll not found' ], 404 );
|
||||||
|
@ -95,8 +96,8 @@ class VoteController extends FramadateController {
|
||||||
404 );
|
404 );
|
||||||
}
|
}
|
||||||
$vote->setPoll( $poll )
|
$vote->setPoll( $poll )
|
||||||
->setChoice( $foundChoice )
|
->setChoice( $foundChoice )
|
||||||
->setValue( $voteInfo[ 'value' ] );
|
->setValue( $voteInfo[ 'value' ] );
|
||||||
$vote->setPoll( $poll );
|
$vote->setPoll( $poll );
|
||||||
$stack->addVote( $vote );
|
$stack->addVote( $vote );
|
||||||
$poll->addVote( $vote );
|
$poll->addVote( $vote );
|
||||||
|
@ -113,7 +114,7 @@ class VoteController extends FramadateController {
|
||||||
if ( $existingOwner ) {
|
if ( $existingOwner ) {
|
||||||
$precision = ' from an existing owner : ' . $foundOwner->getEmail();
|
$precision = ' from an existing owner : ' . $foundOwner->getEmail();
|
||||||
}
|
}
|
||||||
$stacks = $poll->getStacksOfVotes();
|
$stacks = $poll->getStacksOfVotes();
|
||||||
|
|
||||||
if($poll->getMailOnVote()){
|
if($poll->getMailOnVote()){
|
||||||
$this->sendVoteNotificationAction($stack->getOwner(), $stack);
|
$this->sendVoteNotificationAction($stack->getOwner(), $stack);
|
||||||
|
@ -121,36 +122,36 @@ class VoteController extends FramadateController {
|
||||||
|
|
||||||
$returnedVoteStack = $stack;
|
$returnedVoteStack = $stack;
|
||||||
|
|
||||||
$jsonResponse = $serializer->serialize($returnedVoteStack, 'json');
|
$jsonResponse = $serializer->serialize($returnedVoteStack, 'json');
|
||||||
|
|
||||||
$response = new Response($jsonResponse);
|
$response = new Response($jsonResponse);
|
||||||
$response->headers->set('Content-Type', 'application/json');
|
$response->headers->set('Content-Type', 'application/json');
|
||||||
$response->setStatusCode(200);
|
$response->setStatusCode(200);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update vote stack
|
* update vote stack
|
||||||
* @Patch(
|
* @Patch(
|
||||||
* path = "/vote-stack/{id}/token/{modifierToken}",
|
* path = "/vote-stack/{id}/token/{modifierToken}",
|
||||||
* name = "update_vote_stack",
|
* name = "update_vote_stack",
|
||||||
* requirements = { "id"="\d+"}
|
* requirements = { "id"="\d+"}
|
||||||
* )
|
* )
|
||||||
* @param SerializerInterface $serializer
|
* @param SerializerInterface $serializer
|
||||||
* @param StackOfVotes $id
|
* @param StackOfVotes $id
|
||||||
* @param $modifierToken
|
* @param $modifierToken
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
* @return JsonResponse|Response
|
* @return JsonResponse|Response
|
||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
function updateVoteStackAction(
|
function updateVoteStackAction(
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
StackOfVotes $id,
|
StackOfVotes $id,
|
||||||
$modifierToken,
|
$modifierToken,
|
||||||
Request $request
|
Request $request
|
||||||
) {
|
) {
|
||||||
$voteStack = $id;
|
$voteStack = $id;
|
||||||
if ( ! $voteStack ) {
|
if ( ! $voteStack ) {
|
||||||
|
@ -170,17 +171,17 @@ class VoteController extends FramadateController {
|
||||||
// save evrything
|
// save evrything
|
||||||
|
|
||||||
|
|
||||||
$jsonResponse = $serializer->serialize([
|
$jsonResponse = $serializer->serialize([
|
||||||
'message' => 'ok',
|
'message' => 'ok',
|
||||||
'modifier_token' => $voteStack->getOwner()->getModifierToken(),
|
'modifier_token' => $voteStack->getOwner()->getModifierToken(),
|
||||||
'vote_stack' => $voteStack,
|
'vote_stack' => $voteStack,
|
||||||
], 'json');
|
], 'json');
|
||||||
|
|
||||||
$response = new Response($jsonResponse);
|
$response = new Response($jsonResponse);
|
||||||
$response->headers->set('Content-Type', 'application/json');
|
$response->headers->set('Content-Type', 'application/json');
|
||||||
$response->setStatusCode(200);
|
$response->setStatusCode(200);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue