Skip to content

Commit

Permalink
Allow "friendsofsymfony/rest-bundle:^3.0"
Browse files Browse the repository at this point in the history
  • Loading branch information
wbloszyk committed Jul 24, 2020
1 parent 2519ef3 commit b47320d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@
"twig/twig": "^2.12.1"
},
"conflict": {
"friendsofsymfony/rest-bundle": "<2.1 || >=3.0",
"friendsofsymfony/rest-bundle": "<2.1",
"jms/serializer": "<0.13",
"sonata-project/core-bundle": "<3.20"
},
"require-dev": {
"doctrine/annotations": "1.10.3",
"friendsofsymfony/rest-bundle": "^2.1",
"friendsofsymfony/rest-bundle": "^2.6 || ^3.0",
"jms/serializer-bundle": "^2.0 || ^3.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1.1",
"nelmio/api-doc-bundle": "^2.4",
Expand Down
10 changes: 10 additions & 0 deletions src/Controller/Api/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@

namespace Sonata\PageBundle\Controller\Api;

use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\Annotations\View;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Model\BlockManagerInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;

/**
* @author Vincent Composieux <vincent.composieux@gmail.com>
*
* @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"})
*/
class BlockController extends FOSRestController
{
Expand Down Expand Up @@ -57,6 +61,8 @@ public function __construct(BlockManagerInterface $blockManager, FormFactoryInte
* }
* )
*
* @Rest\Get("/blocks/{id}.{_format}", name="get_block")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
Expand Down Expand Up @@ -84,6 +90,8 @@ public function getBlockAction($id)
* }
* )
*
* @Rest\Put("/blocks/{id}.{_format}", name="put_block")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param int $id A Block identifier
Expand Down Expand Up @@ -128,6 +136,8 @@ public function putBlockAction($id, Request $request)
* }
* )
*
* @Rest\Delete("/blocks/{id}.{_format}", name="delete_block")
*
* @param int $id A Block identifier
*
* @throws NotFoundHttpException
Expand Down
24 changes: 24 additions & 0 deletions src/Controller/Api/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\PageBundle\Controller\Api;

use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Request\ParamFetcherInterface;
Expand All @@ -28,9 +29,12 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;

/**
* @author Hugo Briand <briand@ekino.com>
*
* @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"})
*/
class PageController extends FOSRestController
{
Expand Down Expand Up @@ -76,6 +80,8 @@ public function __construct(SiteManagerInterface $siteManager, PageManagerInterf
* output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
* )
*
* @Rest\Get("/pages.{_format}", name="get_pages")
*
* @QueryParam(name="page", requirements="\d+", default="1", description="Page for 'page' list pagination")
* @QueryParam(name="count", requirements="\d+", default="10", description="Number of pages by page")
* @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled pages filter")
Expand Down Expand Up @@ -137,6 +143,8 @@ public function getPagesAction(ParamFetcherInterface $paramFetcher)
* }
* )
*
* @Rest\Get("/page/pages/{id}.{_format}", name="get_page")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
Expand All @@ -162,6 +170,8 @@ public function getPageAction($id)
* }
* )
*
* @Rest\Get("/pages/{id}/blocks.{_format}", name="get_page_blocks")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
Expand All @@ -187,6 +197,8 @@ public function getPageBlocksAction($id)
* }
* )
*
* @Rest\Get("/pages/{id}/pages.{_format}", name="get_page_pages")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
Expand Down Expand Up @@ -216,6 +228,8 @@ public function getPagePagesAction($id)
* }
* )
*
* @Rest\Post("/pages/{id}/blocks.{_format}", name="post_page_block")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param int $id A Page identifier
Expand Down Expand Up @@ -260,6 +274,8 @@ public function postPageBlockAction($id, Request $request)
* }
* )
*
* @Rest\Post("/pages.{_format}", name="post_page")
*
* @param Request $request A Symfony request
*
* @throws NotFoundHttpException
Expand Down Expand Up @@ -287,6 +303,8 @@ public function postPageAction(Request $request)
* }
* )
*
* @Rest\Put("/pages/{id}.{_format}", name="put_page")
*
* @param int $id A Page identifier
* @param Request $request A Symfony request
*
Expand All @@ -313,6 +331,8 @@ public function putPageAction($id, Request $request)
* }
* )
*
* @Rest\Delete("/pages/{id}.{_format}", name="delete_page")
*
* @param int $id A Page identifier
*
* @throws NotFoundHttpException
Expand Down Expand Up @@ -342,6 +362,8 @@ public function deletePageAction($id)
* }
* )
*
* @Rest\Post("/pages/{id}/snapshots.{_format}", name="post_page_snapshot")
*
* @param int $id A Page identifier
*
* @throws NotFoundHttpException
Expand Down Expand Up @@ -369,6 +391,8 @@ public function postPageSnapshotAction($id)
* }
* )
*
* @Rest\Post("/pages/snapshots.{_format}", name="post_pages_snapshots")
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
Expand Down
14 changes: 14 additions & 0 deletions src/Controller/Api/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\PageBundle\Controller\Api;

use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Request\ParamFetcherInterface;
Expand All @@ -24,9 +25,12 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;

/**
* @author Raphaël Benitte <benitteraphael@gmail.com>
*
* @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"})
*/
class SiteController extends FOSRestController
{
Expand Down Expand Up @@ -54,6 +58,8 @@ public function __construct(SiteManagerInterface $siteManager, FormFactoryInterf
* output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
* )
*
* @Rest\Get("/sites.{_format}", name="get_sites")
*
* @QueryParam(name="page", requirements="\d+", default="1", description="Page for site list pagination")
* @QueryParam(name="count", requirements="\d+", default="10", description="Maximum number of sites per page")
* @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled sites filter")
Expand Down Expand Up @@ -108,6 +114,8 @@ public function getSitesAction(ParamFetcherInterface $paramFetcher)
* }
* )
*
* @Rest\Get("/sites/{id}.{_format}", name="get_site")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
Expand All @@ -131,6 +139,8 @@ public function getSiteAction($id)
* }
* )
*
* @Rest\Post("/sites.{_format}", name="post_site")
*
* @param Request $request A Symfony request
*
* @throws NotFoundHttpException
Expand Down Expand Up @@ -158,6 +168,8 @@ public function postSiteAction(Request $request)
* }
* )
*
* @Rest\Put("/sites/{id}.{_format}", name="put_site")
*
* @param int $id A Site identifier
* @param Request $request A Symfony request
*
Expand All @@ -184,6 +196,8 @@ public function putSiteAction($id, Request $request)
* }
* )
*
* @Rest\Delete("/sites/{id}.{_format}", name="delete_site")
*
* @param int $id A Site identifier
*
* @throws NotFoundHttpException
Expand Down
10 changes: 10 additions & 0 deletions src/Controller/Api/SnapshotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Sonata\PageBundle\Controller\Api;

use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Request\ParamFetcherInterface;
Expand All @@ -21,9 +22,12 @@
use Sonata\PageBundle\Model\SnapshotInterface;
use Sonata\PageBundle\Model\SnapshotManagerInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;

/**
* @author Benoit de Jacobet <benoit.de-jacobet@ekino.com>
*
* @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"})
*/
class SnapshotController extends FOSRestController
{
Expand All @@ -45,6 +49,8 @@ public function __construct(SnapshotManagerInterface $snapshotManager)
* output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
* )
*
* @Rest\Get("/snapshots.{_format}", name="get_snapshots")
*
* @QueryParam(name="page", requirements="\d+", default="1", description="Page for snapshots list pagination")
* @QueryParam(name="count", requirements="\d+", default="10", description="Maximum number of snapshots per page")
* @QueryParam(name="site", requirements="\d+", nullable=true, strict=true, description="Filter snapshots for a specific site's id")
Expand Down Expand Up @@ -105,6 +111,8 @@ public function getSnapshotsAction(ParamFetcherInterface $paramFetcher)
* }
* )
*
* @Rest\Get("/snapshots/{id}.{_format}", name="get_snapshot")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
Expand All @@ -130,6 +138,8 @@ public function getSnapshotAction($id)
* }
* )
*
* @Rest\Delete("/snapshots/{id}.{_format}", name="delete_snapshot")
*
* @param int $id A Snapshot identifier
*
* @throws NotFoundHttpException
Expand Down
10 changes: 5 additions & 5 deletions src/Resources/config/routing/api.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://friendsofsymfony.github.com/schema/rest" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://friendsofsymfony.github.com/schema/rest https://raw.github.com/FriendsOfSymfony/FOSRestBundle/master/Resources/config/schema/routing/rest_routing-1.0.xsd">
<import type="rest" resource="Sonata\PageBundle\Controller\Api\BlockController" name-prefix="sonata_api_block_"/>
<import type="rest" resource="Sonata\PageBundle\Controller\Api\PageController" name-prefix="sonata_api_page_"/>
<import type="rest" resource="Sonata\PageBundle\Controller\Api\SiteController" name-prefix="sonata_api_site_"/>
<import type="rest" resource="Sonata\PageBundle\Controller\Api\SnapshotController" name-prefix="sonata_api_snapshot_"/>
<routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
<import type="annotation" resource="Sonata\PageBundle\Controller\Api\BlockController" name-prefix="sonata_api_block_"/>
<import type="annotation" resource="Sonata\PageBundle\Controller\Api\PageController" name-prefix="sonata_api_page_"/>
<import type="annotation" resource="Sonata\PageBundle\Controller\Api\SiteController" name-prefix="sonata_api_site_"/>
<import type="annotation" resource="Sonata\PageBundle\Controller\Api\SnapshotController" name-prefix="sonata_api_snapshot_"/>
</routes>

0 comments on commit b47320d

Please sign in to comment.