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 Aug 5, 2020
1 parent 2519ef3 commit 12a05fb
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 101 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
23 changes: 12 additions & 11 deletions src/Controller/Api/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

namespace Sonata\PageBundle\Controller\Api;

use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\View\View;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Model\BlockManagerInterface;
Expand Down Expand Up @@ -48,7 +49,7 @@ public function __construct(BlockManagerInterface $blockManager, FormFactoryInte
* @ApiDoc(
* resource=true,
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="block id"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Block identifier"}
* },
* output={"class"="Sonata\PageBundle\Model\BlockInterface", "groups"={"sonata_api_read"}},
* statusCodes={
Expand All @@ -57,9 +58,9 @@ public function __construct(BlockManagerInterface $blockManager, FormFactoryInte
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
* @param int $id Block identifier
*
* @return BlockInterface
*/
Expand All @@ -73,7 +74,7 @@ public function getBlockAction($id)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="block identifier"},
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Block identifier"},
* },
* input={"class"="sonata_page_api_form_block", "name"="", "groups"={"sonata_api_write"}},
* output={"class"="Sonata\PageBundle\Model\Block", "groups"={"sonata_api_read"}},
Expand All @@ -84,10 +85,10 @@ public function getBlockAction($id)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param int $id A Block identifier
* @param Request $request A Symfony request
* @param int $id Block identifier
* @param Request $request Symfony request
*
* @throws NotFoundHttpException
*
Expand Down Expand Up @@ -119,7 +120,7 @@ public function putBlockAction($id, Request $request)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="block identifier"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Block identifier"}
* },
* statusCodes={
* 200="Returned when block is successfully deleted",
Expand All @@ -128,11 +129,11 @@ public function putBlockAction($id, Request $request)
* }
* )
*
* @param int $id A Block identifier
* @param int $id Block identifier
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
* @return View
*/
public function deleteBlockAction($id)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Api/FOSRestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use FOS\RestBundle\Context\Context;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\View\View as FOSRestView;
use FOS\RestBundle\View\View;

/**
* @author Duchkina Anastasiya <duchkina.nast@gmail.com>
Expand All @@ -40,15 +40,15 @@ final protected function setMapForOrderByParam(ParamFetcherInterface $paramFetch
/**
* @param $entity
*
* @return FOSRestView
* @return View
*/
final protected function serializeContext($entity, array $groups)
{
$context = new Context();
$context->setGroups($groups);
$context->enableMaxDepth();

$view = FOSRestView::create($entity);
$view = View::create($entity);
$view->setContext($context);

return $view;
Expand Down
80 changes: 41 additions & 39 deletions src/Controller/Api/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

namespace Sonata\PageBundle\Controller\Api;

use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Request\ParamFetcherInterface;
use FOS\RestBundle\View\View;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Model\BlockManagerInterface;
Expand Down Expand Up @@ -76,17 +76,17 @@ public function __construct(SiteManagerInterface $siteManager, PageManagerInterf
* output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}}
* )
*
* @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")
* @QueryParam(name="edited", requirements="0|1", nullable=true, strict=true, description="Edited/Up to date pages filter")
* @QueryParam(name="internal", requirements="0|1", nullable=true, strict=true, description="Internal/Exposed pages filter")
* @QueryParam(name="root", requirements="0|1", nullable=true, strict=true, description="Filter pages having no parent id")
* @QueryParam(name="site", requirements="\d+", nullable=true, strict=true, description="Filter pages for a specific site's id")
* @QueryParam(name="parent", requirements="\d+", nullable=true, strict=true, description="Get pages being child of given page id")
* @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Order by array (key is field, value is direction)")
* @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for 'page' list pagination")
* @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of pages by page")
* @Rest\QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled pages filter")
* @Rest\QueryParam(name="edited", requirements="0|1", nullable=true, strict=true, description="Edited/Up to date pages filter")
* @Rest\QueryParam(name="internal", requirements="0|1", nullable=true, strict=true, description="Internal/Exposed pages filter")
* @Rest\QueryParam(name="root", requirements="0|1", nullable=true, strict=true, description="Filter pages having no parent id")
* @Rest\QueryParam(name="site", requirements="\d+", nullable=true, strict=true, description="Filter pages for a specific site's id")
* @Rest\QueryParam(name="parent", requirements="\d+", nullable=true, strict=true, description="Get pages being child of given page id")
* @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Order by array (key is field, value is direction)")
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @return PagerInterface
*/
Expand Down Expand Up @@ -128,7 +128,7 @@ public function getPagesAction(ParamFetcherInterface $paramFetcher)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page id"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* output={"class"="Sonata\PageBundle\Model\PageInterface", "groups"={"sonata_api_read"}},
* statusCodes={
Expand All @@ -137,9 +137,9 @@ public function getPagesAction(ParamFetcherInterface $paramFetcher)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
* @param int $id Page identifier
*
* @return PageInterface
*/
Expand All @@ -153,7 +153,7 @@ public function getPageAction($id)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page id"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* output={"class"="Sonata\BlockBundle\Model\BlockInterface", "groups"={"sonata_api_read"}},
* statusCodes={
Expand All @@ -162,9 +162,9 @@ public function getPageAction($id)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
* @param int $id Page identifier
*
* @return BlockInterface[]
*/
Expand All @@ -178,7 +178,7 @@ public function getPageBlocksAction($id)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page id"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* output={"class"="Sonata\BlockBundle\Model\BlockInterface", "groups"={"sonata_api_read"}},
* statusCodes={
Expand All @@ -187,9 +187,9 @@ public function getPageBlocksAction($id)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
* @param int $id Page identifier
*
* @return PageInterface[]
*/
Expand All @@ -205,7 +205,7 @@ public function getPagePagesAction($id)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page identifier"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* input={"class"="sonata_page_api_form_block", "name"="", "groups"={"sonata_api_write"}},
* output={"class"="Sonata\PageBundle\Model\Block", "groups"={"sonata_api_read"}},
Expand All @@ -216,10 +216,10 @@ public function getPagePagesAction($id)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param int $id A Page identifier
* @param Request $request A Symfony request
* @param int $id Page identifier
* @param Request $request Symfony request
*
* @throws NotFoundHttpException
*
Expand Down Expand Up @@ -260,7 +260,7 @@ public function postPageBlockAction($id, Request $request)
* }
* )
*
* @param Request $request A Symfony request
* @param Request $request Symfony request
*
* @throws NotFoundHttpException
*
Expand All @@ -276,7 +276,7 @@ public function postPageAction(Request $request)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page identifier"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* input={"class"="sonata_page_api_form_page", "name"="", "groups"={"sonata_api_write"}},
* output={"class"="Sonata\PageBundle\Model\Page", "groups"={"sonata_api_read"}},
Expand All @@ -287,8 +287,10 @@ public function postPageAction(Request $request)
* }
* )
*
* @param int $id A Page identifier
* @param Request $request A Symfony request
* @Rest\Put("", name="")
*
* @param int $id Page identifier
* @param Request $request Symfony request
*
* @throws NotFoundHttpException
*
Expand All @@ -304,7 +306,7 @@ public function putPageAction($id, Request $request)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page identifier"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* statusCodes={
* 200="Returned when page is successfully deleted",
Expand All @@ -313,11 +315,11 @@ public function putPageAction($id, Request $request)
* }
* )
*
* @param int $id A Page identifier
* @param int $id Page identifier
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
* @return View
*/
public function deletePageAction($id)
{
Expand All @@ -333,7 +335,7 @@ public function deletePageAction($id)
*
* @ApiDoc(
* requirements={
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="page identifier"}
* {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Page identifier"}
* },
* statusCodes={
* 200="Returned when snapshots are successfully queued for creation",
Expand All @@ -342,11 +344,11 @@ public function deletePageAction($id)
* }
* )
*
* @param int $id A Page identifier
* @param int $id Page identifier
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
* @return View
*/
public function postPageSnapshotAction($id)
{
Expand All @@ -371,7 +373,7 @@ public function postPageSnapshotAction($id)
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
* @return View
*/
public function postPagesSnapshotsAction()
{
Expand All @@ -389,7 +391,7 @@ public function postPagesSnapshotsAction()
/**
* Retrieves page with id $id or throws an exception if it doesn't exist.
*
* @param $id
* @param mixed $id Page identifier
*
* @throws NotFoundHttpException
*
Expand All @@ -409,7 +411,7 @@ protected function getPage($id)
/**
* Retrieves Block with id $id or throws an exception if it doesn't exist.
*
* @param $id
* @param mixed $id Block identifier
*
* @throws NotFoundHttpException
*
Expand All @@ -430,7 +432,7 @@ protected function getBlock($id)
* Write a page, this method is used by both POST and PUT action methods.
*
* @param Request $request Symfony request
* @param int|null $id A page identifier
* @param int|null $id Page identifier
*
* @return FormInterface
*/
Expand Down
Loading

0 comments on commit 12a05fb

Please sign in to comment.