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

Revert "add graphql bundle"

rearrange controllers for api and no api

This reverts commit 8fbd5462
This commit is contained in:
tykayn 2021-04-21 11:02:24 +02:00
parent 21c594a2fd
commit aab2d74b19
8 changed files with 96 additions and 94 deletions

View File

@ -11,7 +11,7 @@ use FOS\RestBundle\Controller\Annotations\Route;
* @package App\Controller
* @Route("/admin",name="admin_homepage")
*/
class AdminController extends FramadateController {
class AdminController extends EmailsController {
/**
* @Get(path ="/",
* name = "_get_default")

View File

@ -17,7 +17,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
* @package App\Controller
* @Route("/",name="home_")
*/
class DefaultController extends FramadateController {
class DefaultController extends EmailsController {
/**
* @Get(path ="/",
@ -27,7 +27,7 @@ class DefaultController extends FramadateController {
$polls = $this->getDoctrine()->getRepository( Poll::class )->findAll();
return $this->render( 'pages/home.html.twig',[ ]);
return $this->render( 'pages/home.html.twig', [] );
}

View File

@ -11,10 +11,10 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
/**
* sending emails controller
*
* Class FramadateController
* Class EmailsController
* @package App\Controller
*/
class FramadateController extends AbstractController {
class EmailsController extends AbstractController {
private $mail_service;
@ -86,7 +86,7 @@ class FramadateController extends AbstractController {
$config = [
'owner' => $owner,
'title' => 'Framadate | Mes sondages',
'title' => $this->getParameter( 'WEBSITE_NAME' ) . ' | Mes sondages',
'email_template' => 'emails/owner-list.html.twig',
];
$this->sendMailWithVars( $config );

View File

@ -21,7 +21,7 @@ use App\Entity\Poll;
* @package App\Controller
* @Route("/migration-from-v1",name="admin_homepage")
*/
class MigrationController extends FramadateController {
class MigrationController extends EmailsController {
/**
* @Get(path ="/{unique_key}",
* name = "_migrate_from_v1")

View File

@ -14,7 +14,7 @@ use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
* @package App\Controller
* @Route("/user",name="user_homepage")
*/
class OwnerController extends FramadateController {
class OwnerController extends EmailsController {
/**
* @Get(path ="/",
* name = "get_default")

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controller;
namespace App\Controller\api;
use App\Controller\EmailsController;
use App\Entity\Comment;
use App\Entity\Owner;
use App\Entity\Poll;
@ -21,7 +22,7 @@ use Symfony\Component\HttpFoundation\Response;
* @package App\Controller
* @Route("/api/v1",name="api_")
*/
class CommentController extends FramadateController {
class CommentController extends EmailsController {
/**
* @Get(

View File

@ -2,7 +2,7 @@
namespace App\Controller\api;
use App\Controller\FramadateController;
use App\Controller\EmailsController;
use App\Entity\Choice;
use App\Entity\Owner;
use App\Entity\Poll;
@ -27,14 +27,14 @@ use FOS\RestBundle\Controller\Annotations\Route;
* @package App\Controller
* @Route("/api/v1/poll",name="api_")
*/
class PollController extends FramadateController {
class PollController extends EmailsController {
/**
* @Get(
* path = "/",
* name = "get_all_polls"
* )
*/
public function getAllPollsAction(PollRepository $pollRepository): Response {
public function getAllPollsAction( PollRepository $pollRepository ): Response {
$data = $pollRepository->findAll();
@ -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(
* path = "/{id}",
* path = "/{customUrl}",
* name = "get_poll",
* requirements = {"id"="\w+"}
* requirements = {"customUrl"="\w+"}
* )
*
* @param SerializerInterface $serializer
@ -88,14 +88,14 @@ class PollController extends FramadateController {
*/
public function getPollConfig(
SerializerInterface $serializer,
$id,
$customUrl,
Request $request
): Response {
$repository = $this->getDoctrine()->getRepository( Poll::class );
$poll = $repository->findOneByCustomUrl( $id );
$poll = $repository->findOneByCustomUrl( $customUrl );
if ( ! $poll ) {
return $this->notFoundPoll($id);
return $this->notFoundPoll( $customUrl );
}
$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(
* path = "/{id}/pass/{md5}",
* path = "/{customUrl}/pass/{md5}",
* name = "get_protected_poll",
* requirements = {"id"="\w+"}
* requirements = {"customUrl"="\w+"}
* )
*
* @param SerializerInterface $serializer
@ -180,7 +180,7 @@ class PollController extends FramadateController {
/**
* @Put(
* path = "/{id}/{token}",
* path = "/{customUrl}/{token}",
* name = "update_poll",
* requirements = {"content"="\w+", "poll_id"="\d+"}
* )
@ -363,7 +363,7 @@ class PollController extends FramadateController {
/**
* @Delete(
* path = "/{id}",
* path = "/{customUrl}",
* name = "poll_delete",
* requirements = {"accessToken"="\w+", "poll_id"="\d+"}
* )
@ -397,13 +397,13 @@ class PollController extends FramadateController {
/**
* Checks if a slug is already taken by a poll
* @Get(
* path = "/slug/{slug}",
* path = "/slug/{customUrl}",
* name = "check_slug_is_unique",
* )
*/
public function checkSlugIsUniqueAction( string $slug ) {
public function checkSlugIsUniqueAction( string $customUrl ) {
$emPoll = $this->getDoctrine()->getRepository( Poll::class );
$found = $emPoll->findOneByCustomUrl( $slug );
$found = $emPoll->findOneByCustomUrl( $customUrl );
$elaborated_message_version = false;
if ( $found ) {
@ -416,7 +416,7 @@ class PollController extends FramadateController {
return $this->json( [
'message' => ' NO, this slug is already taken on this Framadate instance ',
'data' => [
'slug' => $slug,
'slug' => $customUrl,
],
],
204 );
@ -429,7 +429,7 @@ class PollController extends FramadateController {
return $this->json( [
'message' => ' yes this slug is available on this Framadate instance ',
'data' => [
'slug' => $slug,
'slug' => $customUrl,
],
],
404 );

View File

@ -1,7 +1,8 @@
<?php
namespace App\Controller;
namespace App\Controller\api;
use App\Controller\EmailsController;
use App\Entity\Choice;
use App\Entity\Owner;
use App\Entity\Poll;
@ -21,7 +22,7 @@ use Symfony\Component\HttpFoundation\Response;
* @package App\Controller
* @Route("/api/v1",name="api_")
*/
class VoteController extends FramadateController {
class VoteController extends EmailsController {
/**
* add a vote stack on a poll