diff --git a/composer.json b/composer.json index 5f68e0ad7..5ebd37dfe 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Controller/Api/BlockController.php b/src/Controller/Api/BlockController.php index b94bda047..006178ab5 100644 --- a/src/Controller/Api/BlockController.php +++ b/src/Controller/Api/BlockController.php @@ -13,6 +13,7 @@ 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; @@ -20,9 +21,12 @@ 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 + * + * @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"}) */ class BlockController extends FOSRestController { @@ -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 @@ -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 @@ -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 diff --git a/src/Controller/Api/PageController.php b/src/Controller/Api/PageController.php index 656287609..8d8dfd1ab 100644 --- a/src/Controller/Api/PageController.php +++ b/src/Controller/Api/PageController.php @@ -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; @@ -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 + * + * @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"}) */ class PageController extends FOSRestController { @@ -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") @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 * @@ -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 @@ -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 @@ -369,6 +391,8 @@ public function postPageSnapshotAction($id) * } * ) * + * @Rest\Post("/pages/snapshots.{_format}", name="post_pages_snapshots") + * * @throws NotFoundHttpException * * @return \FOS\RestBundle\View\View diff --git a/src/Controller/Api/SiteController.php b/src/Controller/Api/SiteController.php index f03319964..769fee783 100644 --- a/src/Controller/Api/SiteController.php +++ b/src/Controller/Api/SiteController.php @@ -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; @@ -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 + * + * @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"}) */ class SiteController extends FOSRestController { @@ -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") @@ -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 @@ -131,6 +139,8 @@ public function getSiteAction($id) * } * ) * + * @Rest\Post("/sites.{_format}", name="post_site") + * * @param Request $request A Symfony request * * @throws NotFoundHttpException @@ -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 * @@ -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 diff --git a/src/Controller/Api/SnapshotController.php b/src/Controller/Api/SnapshotController.php index 25f13f89e..a859d0699 100644 --- a/src/Controller/Api/SnapshotController.php +++ b/src/Controller/Api/SnapshotController.php @@ -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; @@ -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 + * + * @Route(defaults={"_format": "json"}, requirements={"_format": "json|xml|html"}) */ class SnapshotController extends FOSRestController { @@ -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") @@ -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 @@ -130,6 +138,8 @@ public function getSnapshotAction($id) * } * ) * + * @Rest\Delete("/snapshots/{id}.{_format}", name="delete_snapshot") + * * @param int $id A Snapshot identifier * * @throws NotFoundHttpException diff --git a/src/Resources/config/routing/api.xml b/src/Resources/config/routing/api.xml index 935140022..45ab155aa 100644 --- a/src/Resources/config/routing/api.xml +++ b/src/Resources/config/routing/api.xml @@ -1,7 +1,7 @@ - - - - - + + + + +