more endpoints

develop
Baptiste Lemoine 3 years ago
parent 8aa8be308e
commit 85f643bcce
  1. 129
      composer.json
  2. 475
      composer.lock
  3. 2
      config/bundles.php
  4. 4
      config/packages/fos_rest.yaml
  5. 3
      config/packages/sensio_framework_extra.yaml
  6. 102
      src/Controller/DefaultController.php
  7. 17
      src/DataFixtures/AppFixtures.php
  8. 22
      src/DataFixtures/AppPollFixtures.php
  9. 27
      symfony.lock

@ -1,69 +1,70 @@
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"friendsofsymfony/rest-bundle": "^2.6",
"jms/serializer-bundle": "^3.4",
"symfony/console": "4.3.*",
"symfony/dotenv": "4.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "4.3.*",
"symfony/framework-bundle": "4.3.*",
"symfony/intl": "4.3.*",
"symfony/orm-pack": "^1.0",
"symfony/validator": "4.3.*",
"symfony/yaml": "4.3.*"
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"friendsofsymfony/rest-bundle": "^2.6",
"jms/serializer-bundle": "^3.4",
"symfony/console": "4.3.*",
"symfony/dotenv": "4.3.*",
"symfony/flex": "^1.3.1",
"symfony/form": "4.3.*",
"symfony/framework-bundle": "4.3.*",
"symfony/intl": "4.3.*",
"symfony/orm-pack": "^1.0",
"symfony/validator": "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": {
"symfony/maker-bundle": "^1.14",
"symfony/web-server-bundle": "4.3.*"
},
"config": {
"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": "*"
"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"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.3.*"
}
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.3.*"
}
}
}

475
composer.lock generated

File diff suppressed because it is too large Load Diff

@ -3,11 +3,11 @@
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
FOS\RestBundle\FOSRestBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::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
# allowed_methods_listener: true
# routing_loader: true
# view:
# view_response_listener: true
# view:
# view_response_listener: true
# exception:
# codes:
# App\Exception\MyException: 403

@ -1,3 +0,0 @@
sensio_framework_extra:
router:
annotations: false

@ -2,8 +2,10 @@
namespace App\Controller;
use App\Entity\Poll;
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;
/**
@ -14,7 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class DefaultController extends AbstractController {
/**
* @Get(path ="/",
* name = "app_get_default")
* name = "get_default")
*/
public function index() {
return $this->json( [
@ -26,13 +28,107 @@ class DefaultController extends AbstractController {
/**
* @Get(
* path = "/my-polls",
* name = "app_get_my_polls",
* name = "get_my_polls",
* requirements = {"access_token"="\w+"}
* )
*/
public function showMyPollsAction() {
return $this->json( [
'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',
] );
}
}

@ -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();
}
}

@ -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();
}
}

@ -20,6 +20,9 @@
"doctrine/common": {
"version": "v2.11.0"
},
"doctrine/data-fixtures": {
"version": "v1.3.2"
},
"doctrine/dbal": {
"version": "v2.9.2"
},
@ -41,6 +44,18 @@
"doctrine/doctrine-cache-bundle": {
"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": {
"version": "1.2",
"recipe": {
@ -170,18 +185,6 @@
"psr/log": {
"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": {
"version": "v4.3.5"
},

Loading…
Cancel
Save