Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "friendsofsymfony/rest-bundle:^3.0" #1175

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
"twig/twig": "^2.12.1"
},
"conflict": {
"friendsofsymfony/rest-bundle": "<2.1 || >=3.0",
"friendsofsymfony/rest-bundle": "<2.1",
core23 marked this conversation as resolved.
Show resolved Hide resolved
"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.1 || ^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
21 changes: 11 additions & 10 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,7 +58,7 @@ public function __construct(BlockManagerInterface $blockManager, FormFactoryInte
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
*
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
68 changes: 34 additions & 34 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,7 +137,7 @@ public function getPagesAction(ParamFetcherInterface $paramFetcher)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
*
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,7 +162,7 @@ public function getPageAction($id)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
*
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,7 +187,7 @@ public function getPageBlocksAction($id)
* }
* )
*
* @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
* @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)
*
* @param $id
*
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,8 @@ public function postPageAction(Request $request)
* }
* )
*
* @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 All @@ -304,7 +304,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 +313,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 +333,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 +342,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 +371,7 @@ public function postPageSnapshotAction($id)
*
* @throws NotFoundHttpException
*
* @return \FOS\RestBundle\View\View
* @return View
*/
public function postPagesSnapshotsAction()
{
Expand Down Expand Up @@ -430,7 +430,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