mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
⚡ more endpoints
This commit is contained in:
parent
8aa8be308e
commit
85f643bcce
131
composer.json
131
composer.json
@ -1,69 +1,70 @@
|
|||||||
{
|
{
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
"friendsofsymfony/rest-bundle": "^2.6",
|
"friendsofsymfony/rest-bundle": "^2.6",
|
||||||
"jms/serializer-bundle": "^3.4",
|
"jms/serializer-bundle": "^3.4",
|
||||||
"symfony/console": "4.3.*",
|
"symfony/console": "4.3.*",
|
||||||
"symfony/dotenv": "4.3.*",
|
"symfony/dotenv": "4.3.*",
|
||||||
"symfony/flex": "^1.3.1",
|
"symfony/flex": "^1.3.1",
|
||||||
"symfony/form": "4.3.*",
|
"symfony/form": "4.3.*",
|
||||||
"symfony/framework-bundle": "4.3.*",
|
"symfony/framework-bundle": "4.3.*",
|
||||||
"symfony/intl": "4.3.*",
|
"symfony/intl": "4.3.*",
|
||||||
"symfony/orm-pack": "^1.0",
|
"symfony/orm-pack": "^1.0",
|
||||||
"symfony/validator": "4.3.*",
|
"symfony/validator": "4.3.*",
|
||||||
"symfony/yaml": "4.3.*"
|
"symfony/yaml": "4.3.*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/doctrine-fixtures-bundle": "^3.2",
|
||||||
|
"symfony/maker-bundle": "^1.14",
|
||||||
|
"symfony/web-server-bundle": "4.3.*"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"preferred-install": {
|
||||||
|
"*": "dist"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"sort-packages": true
|
||||||
"symfony/maker-bundle": "^1.14",
|
},
|
||||||
"symfony/web-server-bundle": "4.3.*"
|
"autoload": {
|
||||||
},
|
"psr-4": {
|
||||||
"config": {
|
"App\\": "src/"
|
||||||
"preferred-install": {
|
|
||||||
"*": "dist"
|
|
||||||
},
|
|
||||||
"sort-packages": true
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"App\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4": {
|
|
||||||
"App\\Tests\\": "tests/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"replace": {
|
|
||||||
"paragonie/random_compat": "2.*",
|
|
||||||
"symfony/polyfill-ctype": "*",
|
|
||||||
"symfony/polyfill-iconv": "*",
|
|
||||||
"symfony/polyfill-php71": "*",
|
|
||||||
"symfony/polyfill-php70": "*",
|
|
||||||
"symfony/polyfill-php56": "*"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"auto-scripts": {
|
|
||||||
"cache:clear": "symfony-cmd",
|
|
||||||
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
|
||||||
},
|
|
||||||
"post-install-cmd": [
|
|
||||||
"@auto-scripts"
|
|
||||||
],
|
|
||||||
"post-update-cmd": [
|
|
||||||
"@auto-scripts"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"symfony/symfony": "*"
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"symfony": {
|
|
||||||
"allow-contrib": false,
|
|
||||||
"require": "4.3.*"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"replace": {
|
||||||
|
"paragonie/random_compat": "2.*",
|
||||||
|
"symfony/polyfill-ctype": "*",
|
||||||
|
"symfony/polyfill-iconv": "*",
|
||||||
|
"symfony/polyfill-php71": "*",
|
||||||
|
"symfony/polyfill-php70": "*",
|
||||||
|
"symfony/polyfill-php56": "*"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"auto-scripts": {
|
||||||
|
"cache:clear": "symfony-cmd",
|
||||||
|
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
||||||
|
},
|
||||||
|
"post-install-cmd": [
|
||||||
|
"@auto-scripts"
|
||||||
|
],
|
||||||
|
"post-update-cmd": [
|
||||||
|
"@auto-scripts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/symfony": "*"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"symfony": {
|
||||||
|
"allow-contrib": false,
|
||||||
|
"require": "4.3.*"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
513
composer.lock
generated
513
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,11 @@
|
|||||||
return [
|
return [
|
||||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||||
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
|
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
|
||||||
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
|
|
||||||
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
|
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
|
||||||
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
|
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
|
||||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||||
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
|
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
|
||||||
|
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||||
];
|
];
|
||||||
|
@ -3,8 +3,8 @@ fos_rest:
|
|||||||
# param_fetcher_listener: true
|
# param_fetcher_listener: true
|
||||||
# allowed_methods_listener: true
|
# allowed_methods_listener: true
|
||||||
# routing_loader: true
|
# routing_loader: true
|
||||||
# view:
|
# view:
|
||||||
# view_response_listener: true
|
# view_response_listener: true
|
||||||
# exception:
|
# exception:
|
||||||
# codes:
|
# codes:
|
||||||
# App\Exception\MyException: 403
|
# App\Exception\MyException: 403
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
sensio_framework_extra:
|
|
||||||
router:
|
|
||||||
annotations: false
|
|
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\Poll;
|
||||||
use FOS\RestBundle\Controller\Annotations\Get;
|
use FOS\RestBundle\Controller\Annotations\Get;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use FOS\RestBundle\Controller\Annotations\Post;
|
||||||
|
use FOS\RestBundle\Controller\Annotations\Route;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,7 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
class DefaultController extends AbstractController {
|
class DefaultController extends AbstractController {
|
||||||
/**
|
/**
|
||||||
* @Get(path ="/",
|
* @Get(path ="/",
|
||||||
* name = "app_get_default")
|
* name = "get_default")
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
@ -26,13 +28,107 @@ class DefaultController extends AbstractController {
|
|||||||
/**
|
/**
|
||||||
* @Get(
|
* @Get(
|
||||||
* path = "/my-polls",
|
* path = "/my-polls",
|
||||||
* name = "app_get_my_polls",
|
* name = "get_my_polls",
|
||||||
* requirements = {"access_token"="\w+"}
|
* requirements = {"access_token"="\w+"}
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function showMyPollsAction() {
|
public function showMyPollsAction() {
|
||||||
return $this->json( [
|
return $this->json( [
|
||||||
'message' => 'here are your polls',
|
'message' => 'here are your polls',
|
||||||
|
'data' => new Poll(),
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Get(
|
||||||
|
* path = "/poll/{id}/comments",
|
||||||
|
* name = "get_poll_comment",
|
||||||
|
* requirements = {"id"="\d+"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function getPollCommentsAction() {
|
||||||
|
return $this->json( [
|
||||||
|
'message' => 'here are your comments of the poll',
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Get(
|
||||||
|
* path = "/poll/all",
|
||||||
|
* name = "get_all_polls"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function getAllPollsAction() {
|
||||||
|
$repository = $this->getDoctrine()->getRepository( Poll::class );
|
||||||
|
$polls = $repository->findall();
|
||||||
|
|
||||||
|
|
||||||
|
return $this->json( [
|
||||||
|
'message' => 'here are your polls',
|
||||||
|
'data' => $polls,
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Post(
|
||||||
|
* path = "/poll/new",
|
||||||
|
* name = "new_polls",
|
||||||
|
* requirements = {"creator"="\w+"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function newPollAction( Poll $poll ) {
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
|
$em->persist( $poll );
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
// return $poll;
|
||||||
|
|
||||||
|
return $this->json( $poll );
|
||||||
|
|
||||||
|
// return $this->json( [
|
||||||
|
// 'message' => 'you created a poll',
|
||||||
|
// ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Get(
|
||||||
|
* path = "/poll/{id}",
|
||||||
|
* name = "get_poll",
|
||||||
|
* requirements = {"id"="\d+"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function getPollConfig( Poll $poll ) {
|
||||||
|
return $this->json( [
|
||||||
|
'message' => 'your poll config',
|
||||||
|
'data' => $poll,
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Post(
|
||||||
|
* path = "/poll/{id}/up",
|
||||||
|
* name = "up_poll",
|
||||||
|
* requirements = {"content"="\w+"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function updatePollConfig( Poll $poll ) {
|
||||||
|
return $this->json( [
|
||||||
|
'message' => 'you updated the poll',
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Post(
|
||||||
|
* path = "/comment/new",
|
||||||
|
* name = "new_comment",
|
||||||
|
* requirements = {"content"="\w+"}
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
public function newCommentAction() {
|
||||||
|
return $this->json( [
|
||||||
|
'message' => 'you created a comment',
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
17
src/DataFixtures/AppFixtures.php
Normal file
17
src/DataFixtures/AppFixtures.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class AppFixtures extends Fixture
|
||||||
|
{
|
||||||
|
public function load(ObjectManager $manager)
|
||||||
|
{
|
||||||
|
// $product = new Product();
|
||||||
|
// $manager->persist($product);
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
22
src/DataFixtures/AppPollFixtures.php
Normal file
22
src/DataFixtures/AppPollFixtures.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DataFixtures;
|
||||||
|
|
||||||
|
use App\Entity\Poll;
|
||||||
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
|
use Doctrine\Common\Persistence\ObjectManager;
|
||||||
|
|
||||||
|
class AppPollFixtures extends Fixture {
|
||||||
|
public function load( ObjectManager $manager ) {
|
||||||
|
// $product = new Product();
|
||||||
|
$poll = new Poll();
|
||||||
|
$poll->setTitle( 'démo sondage de texte' );
|
||||||
|
$poll->setCreationDate( new \DateTime() );
|
||||||
|
|
||||||
|
$poll->setExpiracyDate( new \DateTime( ( time() + 3600 * 24 ) ) );
|
||||||
|
|
||||||
|
$manager->persist( $poll );
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
}
|
||||||
|
}
|
27
symfony.lock
27
symfony.lock
@ -20,6 +20,9 @@
|
|||||||
"doctrine/common": {
|
"doctrine/common": {
|
||||||
"version": "v2.11.0"
|
"version": "v2.11.0"
|
||||||
},
|
},
|
||||||
|
"doctrine/data-fixtures": {
|
||||||
|
"version": "v1.3.2"
|
||||||
|
},
|
||||||
"doctrine/dbal": {
|
"doctrine/dbal": {
|
||||||
"version": "v2.9.2"
|
"version": "v2.9.2"
|
||||||
},
|
},
|
||||||
@ -41,6 +44,18 @@
|
|||||||
"doctrine/doctrine-cache-bundle": {
|
"doctrine/doctrine-cache-bundle": {
|
||||||
"version": "1.3.5"
|
"version": "1.3.5"
|
||||||
},
|
},
|
||||||
|
"doctrine/doctrine-fixtures-bundle": {
|
||||||
|
"version": "3.0",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "master",
|
||||||
|
"version": "3.0",
|
||||||
|
"ref": "fc52d86631a6dfd9fdf3381d0b7e3df2069e51b3"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src/DataFixtures/AppFixtures.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
"doctrine/doctrine-migrations-bundle": {
|
"doctrine/doctrine-migrations-bundle": {
|
||||||
"version": "1.2",
|
"version": "1.2",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
@ -170,18 +185,6 @@
|
|||||||
"psr/log": {
|
"psr/log": {
|
||||||
"version": "1.1.0"
|
"version": "1.1.0"
|
||||||
},
|
},
|
||||||
"sensio/framework-extra-bundle": {
|
|
||||||
"version": "5.2",
|
|
||||||
"recipe": {
|
|
||||||
"repo": "github.com/symfony/recipes",
|
|
||||||
"branch": "master",
|
|
||||||
"version": "5.2",
|
|
||||||
"ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"config/packages/sensio_framework_extra.yaml"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"symfony/cache": {
|
"symfony/cache": {
|
||||||
"version": "v4.3.5"
|
"version": "v4.3.5"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user