diff --git a/composer.json b/composer.json index 6260e68b6..527f435ff 100644 --- a/composer.json +++ b/composer.json @@ -63,12 +63,12 @@ "twig/twig": "^2.12.1" }, "conflict": { - "friendsofsymfony/rest-bundle": "<2.2 || >=3.0", + "friendsofsymfony/rest-bundle": "<2.2", "jms/serializer": "<0.13", "sonata-project/core-bundle": "<3.20" }, "require-dev": { - "friendsofsymfony/rest-bundle": "^2.2", + "friendsofsymfony/rest-bundle": "^2.2 || ^3.0", "jms/serializer-bundle": "^2.0 || ^3.0", "matthiasnoback/symfony-config-test": "^4.0", "matthiasnoback/symfony-dependency-injection-test": "^4.0", diff --git a/src/BasketBundle/Controller/Api/BasketController.php b/src/BasketBundle/Controller/Api/BasketController.php index a07782091..4541e4e8e 100644 --- a/src/BasketBundle/Controller/Api/BasketController.php +++ b/src/BasketBundle/Controller/Api/BasketController.php @@ -14,8 +14,7 @@ namespace Sonata\BasketBundle\Controller\Api; use FOS\RestBundle\Context\Context; -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 as FOSRestView; use Nelmio\ApiDocBundle\Annotation\ApiDoc; @@ -26,6 +25,7 @@ use Sonata\Component\Basket\BasketManagerInterface; use Sonata\Component\Product\ProductInterface; use Sonata\Component\Product\ProductManagerInterface; +use Sonata\DatagridBundle\Pager\PagerInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\Request; @@ -63,11 +63,11 @@ class BasketController protected $formFactory; /** - * @param BasketManagerInterface $basketManager A Sonata ecommerce basket manager - * @param BasketElementManagerInterface $basketElementManager A Sonata ecommerce basket element manager - * @param ProductManagerInterface $productManager A Sonata ecommerce product manager - * @param BasketBuilderInterface $basketBuilder A Sonata ecommerce basket builder - * @param FormFactoryInterface $formFactory A Symfony form factory + * @param BasketManagerInterface $basketManager Sonata ecommerce basket manager + * @param BasketElementManagerInterface $basketElementManager Sonata ecommerce basket element manager + * @param ProductManagerInterface $productManager Sonata ecommerce product manager + * @param BasketBuilderInterface $basketBuilder Sonata ecommerce basket builder + * @param FormFactoryInterface $formFactory Symfony form factory */ public function __construct(BasketManagerInterface $basketManager, BasketElementManagerInterface $basketElementManager, ProductManagerInterface $productManager, BasketBuilderInterface $basketBuilder, FormFactoryInterface $formFactory) { @@ -86,13 +86,13 @@ public function __construct(BasketManagerInterface $basketManager, BasketElement * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for baskets list pagination (1-indexed)") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of baskets by page") - * @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") + * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for baskets list pagination (1-indexed)") + * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of baskets by page") + * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @return \Sonata\DatagridBundle\Pager\PagerInterface + * @return PagerInterface */ public function getBasketsAction(ParamFetcherInterface $paramFetcher) { @@ -125,7 +125,7 @@ public function getBasketsAction(ParamFetcherInterface $paramFetcher) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="basket id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"} * }, * output={"class"="Sonata\Component\Basket\BasketInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -134,7 +134,7 @@ public function getBasketsAction(ParamFetcherInterface $paramFetcher) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -150,7 +150,7 @@ public function getBasketAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="basket id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"} * }, * output={"class"="Sonata\Component\Basket\BasketInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -159,7 +159,7 @@ public function getBasketAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -183,7 +183,7 @@ public function getBasketBasketelementsAction($id) * } * ) * - * @param Request $request A Symfony request + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -197,7 +197,7 @@ public function postBasketAction(Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="basket identifier"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"} * }, * input={"class"="sonata_basket_api_form_basket", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\Component\Basket\BasketInterface", "groups"={"sonata_api_read"}}, @@ -208,8 +208,8 @@ public function postBasketAction(Request $request) * } * ) * - * @param int $id A Basket identifier - * @param Request $request A Symfony request + * @param int $id Basket identifier + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -223,7 +223,7 @@ public function putBasketAction($id, Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="basket identifier"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"} * }, * statusCodes={ * 200="Returned when basket is successfully deleted", @@ -232,11 +232,11 @@ public function putBasketAction($id, Request $request) * } * ) * - * @param int $id A Basket identifier + * @param int $id Basket identifier * * @throws NotFoundHttpException * - * @return \FOS\RestBundle\View\View + * @return FOSRestView */ public function deleteBasketAction($id) { @@ -256,7 +256,7 @@ public function deleteBasketAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="basket identifier"}, + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"}, * }, * input={"class"="sonata_basket_api_form_basket_element", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\Component\Basket\BasketInterface", "groups"={"sonata_api_read"}}, @@ -267,8 +267,8 @@ public function deleteBasketAction($id) * } * ) * - * @param int $id A basket identifier - * @param Request $request A Symfony request + * @param int $id Basket identifier + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -282,8 +282,8 @@ public function postBasketBasketelementsAction($id, Request $request) * * @ApiDoc( * requirements={ - * {"name"="basketId", "dataType"="integer", "requirement"="\d+", "description"="basket identifier"}, - * {"name"="elementId", "dataType"="integer", "requirement"="\d+", "description"="element identifier"}, + * {"name"="basketId", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"}, + * {"name"="elementId", "dataType"="integer", "requirement"="\d+", "description"="Element identifier"}, * }, * input={"class"="sonata_basket_api_form_basket_element", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\Component\Basket\BasketInterface", "groups"={"sonata_api_read"}}, @@ -294,9 +294,9 @@ public function postBasketBasketelementsAction($id, Request $request) * } * ) * - * @param int $basketId A basket identifier - * @param int $elementId A basket element identifier - * @param Request $request A Symfony request + * @param int $basketId Basket identifier + * @param int $elementId Basket element identifier + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -310,8 +310,8 @@ public function putBasketBasketelementsAction($basketId, $elementId, Request $re * * @ApiDoc( * requirements={ - * {"name"="basketId", "dataType"="integer", "requirement"="\d+", "description"="basket identifier"}, - * {"name"="elementId", "dataType"="integer", "requirement"="\d+", "description"="element identifier"}, + * {"name"="basketId", "dataType"="integer", "requirement"="\d+", "description"="Basket identifier"}, + * {"name"="elementId", "dataType"="integer", "requirement"="\d+", "description"="Element identifier"}, * }, * statusCodes={ * 200="Returned when basket is successfully deleted", @@ -320,12 +320,12 @@ public function putBasketBasketelementsAction($basketId, $elementId, Request $re * } * ) * - * @param int $basketId A basket identifier - * @param int $elementId A basket element identifier + * @param int $basketId Basket identifier + * @param int $elementId Basket element identifier * * @throws NotFoundHttpException * - * @return \FOS\RestBundle\View\View + * @return FOSRestView */ public function deleteBasketBasketelementsAction($basketId, $elementId) { @@ -368,9 +368,9 @@ public function deleteBasketBasketelementsAction($basketId, $elementId) * Write a basket, this method is used by both POST and PUT action methods. * * @param Request $request Symfony request - * @param int|null $id A basket identifier + * @param int|null $id Basket identifier * - * @return \FOS\RestBundle\View\View|FormInterface + * @return FOSRestView|FormInterface */ protected function handleWriteBasket($request, $id = null) { @@ -411,11 +411,11 @@ protected function handleWriteBasket($request, $id = null) /** * Write a basket element, this method is used by both POST and PUT action methods. * - * @param int $basketId A Sonata ecommerce basket identifier - * @param Request $request A Symfony Request service - * @param int $elementId A Sonata ecommerce basket element identifier + * @param int $basketId Sonata ecommerce basket identifier + * @param Request $request Symfony Request service + * @param int $elementId Sonata ecommerce basket element identifier * - * @return \FOS\RestBundle\View\View|FormInterface + * @return FOSRestView|FormInterface */ protected function handleWriteBasketElement($basketId, $request, $elementId = null) { @@ -469,11 +469,11 @@ protected function handleWriteBasketElement($basketId, $request, $elementId = nu } /** - * Retrieves basket with id $id or throws an exception if it doesn't exist. + * Retrieves basket with identifier $id or throws an exception if it doesn't exist. * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return BasketInterface */ @@ -489,11 +489,11 @@ protected function getBasket($id) } /** - * Retrieves basket element with id $id or throws an exception if it doesn't exist. + * Retrieves basket element with identifier $id or throws an exception if it doesn't exist. * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return BasketElementInterface */ @@ -509,11 +509,11 @@ protected function getBasketElement($id) } /** - * Retrieves product with id $id or throws an exception if it doesn't exist. + * Retrieves product with identifier $id or throws an exception if it doesn't exist. * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return ProductInterface */ @@ -529,11 +529,11 @@ protected function getProduct($id) } /** - * Throws an exception if it already exists a basket with a specific customer id. + * Throws an exception if it already exists a basket with a specific customer identifier. * - * @param $customerId + * @param mixed $customerId Customer identifier * - * @throws \Symfony\Component\HttpKernel\Exception\HttpException + * @throws HttpException */ protected function checkExistingCustomerBasket($customerId): void { diff --git a/src/BasketBundle/Resources/config/routing/api.xml b/src/BasketBundle/Resources/config/routing/api.xml index a1383cdad..520bf8438 100644 --- a/src/BasketBundle/Resources/config/routing/api.xml +++ b/src/BasketBundle/Resources/config/routing/api.xml @@ -1,4 +1,4 @@ - - + + diff --git a/src/BasketBundle/Resources/config/routing/api/basket.xml b/src/BasketBundle/Resources/config/routing/api/basket.xml new file mode 100644 index 000000000..53dcb6640 --- /dev/null +++ b/src/BasketBundle/Resources/config/routing/api/basket.xml @@ -0,0 +1,27 @@ + + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + diff --git a/src/CustomerBundle/Controller/Api/AddressController.php b/src/CustomerBundle/Controller/Api/AddressController.php index 9a91cc0b8..db8aa535b 100644 --- a/src/CustomerBundle/Controller/Api/AddressController.php +++ b/src/CustomerBundle/Controller/Api/AddressController.php @@ -14,13 +14,13 @@ namespace Sonata\CustomerBundle\Controller\Api; use FOS\RestBundle\Context\Context; -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 as FOSRestView; use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Sonata\Component\Customer\AddressInterface; use Sonata\Component\Customer\AddressManagerInterface; +use Sonata\DatagridBundle\Pager\PagerInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -54,14 +54,14 @@ public function __construct(AddressManagerInterface $addressManager, FormFactory * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for addresses list pagination (1-indexed)") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of addresses by page") - * @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") - * @QueryParam(name="customer", requirements="\d+", nullable=true, strict=true, description="Filter on customer id") + * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for addresses list pagination (1-indexed)") + * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of addresses by page") + * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") + * @Rest\QueryParam(name="customer", requirements="\d+", nullable=true, strict=true, description="Filter on customer id") * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @return \Sonata\DatagridBundle\Pager\PagerInterface + * @return PagerInterface */ public function getAddressesAction(ParamFetcherInterface $paramFetcher) { @@ -95,7 +95,7 @@ public function getAddressesAction(ParamFetcherInterface $paramFetcher) * @ApiDoc( * resource=true, * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="address id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Address identifier"} * }, * output={"class"="Sonata\Component\Customer\AddressInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -104,7 +104,7 @@ public function getAddressesAction(ParamFetcherInterface $paramFetcher) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -127,7 +127,7 @@ public function getAddressAction($id) * } * ) * - * @param Request $request A Symfony request + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -141,7 +141,7 @@ public function postAddressAction(Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="address id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Address identifier"} * }, * input={"class"="sonata_customer_api_form_address", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\CustomerBundle\Model\Address", "groups"={"sonata_api_read"}}, @@ -151,8 +151,8 @@ public function postAddressAction(Request $request) * } * ) * - * @param int $id An Address identifier - * @param Request $request A Symfony request + * @param int $id Address identifier + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -166,7 +166,7 @@ public function putAddressAction($id, Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="address identifier"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Address identifier"} * }, * statusCodes={ * 200="Returned when customer is successfully deleted", @@ -175,11 +175,11 @@ public function putAddressAction($id, Request $request) * } * ) * - * @param int $id An Address identifier + * @param int $id Address identifier * * @throws NotFoundHttpException * - * @return \FOS\RestBundle\View\View + * @return FOSRestView */ public function deleteAddressAction($id) { @@ -195,11 +195,11 @@ public function deleteAddressAction($id) } /** - * Retrieves address with id $id or throws an exception if it doesn't exist. + * Retrieves address with identifier $id or throws an exception if it doesn't exist. * * @param int $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return AddressInterface */ @@ -218,9 +218,9 @@ protected function getAddress($id) * Write an address, this method is used by both POST and PUT action methods. * * @param Request $request Symfony request - * @param int|null $id An Address identifier + * @param int|null $id Address identifier * - * @return \FOS\RestBundle\View\View|FormInterface + * @return FOSRestView|FormInterface */ protected function handleWriteAddress($request, $id = null) { diff --git a/src/CustomerBundle/Controller/Api/CustomerController.php b/src/CustomerBundle/Controller/Api/CustomerController.php index 3f5d6d4e4..73969e92d 100644 --- a/src/CustomerBundle/Controller/Api/CustomerController.php +++ b/src/CustomerBundle/Controller/Api/CustomerController.php @@ -14,8 +14,7 @@ namespace Sonata\CustomerBundle\Controller\Api; use FOS\RestBundle\Context\Context; -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 as FOSRestView; use Nelmio\ApiDocBundle\Annotation\ApiDoc; @@ -23,6 +22,7 @@ use Sonata\Component\Customer\CustomerInterface; use Sonata\Component\Customer\CustomerManagerInterface; use Sonata\Component\Order\OrderManagerInterface; +use Sonata\DatagridBundle\Pager\PagerInterface; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -38,12 +38,12 @@ class CustomerController protected $addressManager; /** - * @var \Sonata\Component\Customer\CustomerManagerInterface + * @var CustomerManagerInterface */ protected $customerManager; /** - * @var \Sonata\Component\Order\OrderManagerInterface + * @var OrderManagerInterface */ protected $orderManager; @@ -68,13 +68,13 @@ public function __construct(CustomerManagerInterface $customerManager, OrderMana * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for customers list pagination (1-indexed)") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of customers by page") - * @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") + * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for customers list pagination (1-indexed)") + * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of customers by page") + * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @return \Sonata\DatagridBundle\Pager\PagerInterface + * @return PagerInterface */ public function getCustomersAction(ParamFetcherInterface $paramFetcher) { @@ -107,7 +107,7 @@ public function getCustomersAction(ParamFetcherInterface $paramFetcher) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Customer identifier"} * }, * output={"class"="Sonata\Component\Customer\CustomerInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -116,7 +116,7 @@ public function getCustomersAction(ParamFetcherInterface $paramFetcher) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -139,7 +139,7 @@ public function getCustomerAction($id) * } * ) * - * @param Request $request A Symfony request + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -153,7 +153,7 @@ public function postCustomerAction(Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer identifier"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Customer identifier"} * }, * input={"class"="sonata_customer_api_form_customer", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\CustomerBundle\Model\Customer", "groups"={"sonata_api_read"}}, @@ -164,8 +164,8 @@ public function postCustomerAction(Request $request) * } * ) * - * @param int $id A Customer identifier - * @param Request $request A Symfony request + * @param int $id Customer identifier + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -179,7 +179,7 @@ public function putCustomerAction($id, Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer identifier"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Customer identifier"} * }, * statusCodes={ * 200="Returned when customer is successfully deleted", @@ -188,11 +188,11 @@ public function putCustomerAction($id, Request $request) * } * ) * - * @param int $id A Customer identifier + * @param int $id Customer identifier * * @throws NotFoundHttpException * - * @return \FOS\RestBundle\View\View + * @return FOSRestView */ public function deleteCustomerAction($id) { @@ -212,7 +212,7 @@ public function deleteCustomerAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Customer identifier"} * }, * output={"class"="Sonata\Component\Order\OrderInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -221,7 +221,7 @@ public function deleteCustomerAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -239,7 +239,7 @@ public function getCustomerOrdersAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Customer identifier"} * }, * output={"class"="Sonata\Component\Customer\AddressInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -248,7 +248,7 @@ public function getCustomerOrdersAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -264,7 +264,7 @@ public function getCustomerAddressesAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Customer identifier"} * }, * input={"class"="sonata_customer_api_form_address", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\CustomerBundle\Model\Address", "groups"={"sonata_api_read"}}, @@ -274,10 +274,10 @@ public function getCustomerAddressesAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @param int $id A Customer identifier - * @param Request $request A Symfony request + * @param int $id Customer identifier + * @param Request $request Symfony request * * @throws NotFoundHttpException * @@ -309,9 +309,9 @@ public function postCustomerAddressAction($id, Request $request) * Write a customer, this method is used by both POST and PUT action methods. * * @param Request $request Symfony request - * @param int|null $id A customer identifier + * @param int|null $id Customer identifier * - * @return \FOS\RestBundle\View\View|FormInterface + * @return FOSRestView|FormInterface */ protected function handleWriteCustomer($request, $id = null) { @@ -347,11 +347,11 @@ protected function handleWriteCustomer($request, $id = null) } /** - * Retrieves customer with id $id or throws an exception if it doesn't exist. + * Retrieves customer with identifier $id or throws an exception if it doesn't exist. * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return CustomerInterface */ diff --git a/src/CustomerBundle/Resources/config/routing/api.xml b/src/CustomerBundle/Resources/config/routing/api.xml index eaf16f864..b9fd2c1f2 100644 --- a/src/CustomerBundle/Resources/config/routing/api.xml +++ b/src/CustomerBundle/Resources/config/routing/api.xml @@ -1,5 +1,5 @@ - - - + + + diff --git a/src/CustomerBundle/Resources/config/routing/api/address.xml b/src/CustomerBundle/Resources/config/routing/api/address.xml new file mode 100644 index 000000000..d54976562 --- /dev/null +++ b/src/CustomerBundle/Resources/config/routing/api/address.xml @@ -0,0 +1,18 @@ + + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + diff --git a/src/CustomerBundle/Resources/config/routing/api/customer.xml b/src/CustomerBundle/Resources/config/routing/api/customer.xml new file mode 100644 index 000000000..ed60f4dd7 --- /dev/null +++ b/src/CustomerBundle/Resources/config/routing/api/customer.xml @@ -0,0 +1,27 @@ + + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + diff --git a/src/InvoiceBundle/Controller/Api/InvoiceController.php b/src/InvoiceBundle/Controller/Api/InvoiceController.php index 8616a4052..d0532a573 100644 --- a/src/InvoiceBundle/Controller/Api/InvoiceController.php +++ b/src/InvoiceBundle/Controller/Api/InvoiceController.php @@ -13,12 +13,12 @@ namespace Sonata\InvoiceBundle\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 Nelmio\ApiDocBundle\Annotation\ApiDoc; use Sonata\Component\Invoice\InvoiceInterface; use Sonata\Component\Invoice\InvoiceManagerInterface; +use Sonata\DatagridBundle\Pager\PagerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -27,7 +27,7 @@ class InvoiceController { /** - * @var \Sonata\Component\Invoice\InvoiceManagerInterface + * @var InvoiceManagerInterface */ protected $invoiceManager; @@ -44,14 +44,14 @@ public function __construct(InvoiceManagerInterface $invoiceManager) * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for invoices list pagination") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of invoices by page") - * @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") - * @QueryParam(name="status", requirements="\d+", nullable=true, strict=true, description="Filter on invoice statuses") + * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for invoices list pagination") + * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of invoices by page") + * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") + * @Rest\QueryParam(name="status", requirements="\d+", nullable=true, strict=true, description="Filter on invoice statuses") * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @return \Sonata\DatagridBundle\Pager\PagerInterface + * @return PagerInterface */ public function getInvoicesAction(ParamFetcherInterface $paramFetcher) { @@ -84,7 +84,7 @@ public function getInvoicesAction(ParamFetcherInterface $paramFetcher) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="invoice id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Invoice identifier"} * }, * output={"class"="Sonata\Component\Invoice\InvoiceInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -93,7 +93,7 @@ public function getInvoicesAction(ParamFetcherInterface $paramFetcher) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -109,7 +109,7 @@ public function getInvoiceAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="invoice id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Invoice identifier"} * }, * output={"class"="Sonata\Component\Invoice\InvoiceElementInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -118,7 +118,7 @@ public function getInvoiceAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -130,11 +130,11 @@ public function getInvoiceInvoiceelementsAction($id) } /** - * Retrieves invoice with id $id or throws an exception if it doesn't exist. + * Retrieves invoice with identifier $id or throws an exception if it doesn't exist. * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return InvoiceInterface */ diff --git a/src/InvoiceBundle/Resources/config/routing/api.xml b/src/InvoiceBundle/Resources/config/routing/api.xml index ffe15eeaf..1f7c262c1 100644 --- a/src/InvoiceBundle/Resources/config/routing/api.xml +++ b/src/InvoiceBundle/Resources/config/routing/api.xml @@ -1,4 +1,4 @@ - - + + diff --git a/src/InvoiceBundle/Resources/config/routing/api/invoice.xml b/src/InvoiceBundle/Resources/config/routing/api/invoice.xml new file mode 100644 index 000000000..728714c9e --- /dev/null +++ b/src/InvoiceBundle/Resources/config/routing/api/invoice.xml @@ -0,0 +1,12 @@ + + + + json|xml|html + + + json|xml|html + + + json|xml|html + + diff --git a/src/OrderBundle/Controller/Api/OrderController.php b/src/OrderBundle/Controller/Api/OrderController.php index c9fd6a856..ade6b2afc 100644 --- a/src/OrderBundle/Controller/Api/OrderController.php +++ b/src/OrderBundle/Controller/Api/OrderController.php @@ -13,12 +13,12 @@ namespace Sonata\OrderBundle\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 Nelmio\ApiDocBundle\Annotation\ApiDoc; use Sonata\Component\Order\OrderInterface; use Sonata\Component\Order\OrderManagerInterface; +use Sonata\DatagridBundle\Pager\PagerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -44,15 +44,15 @@ public function __construct(OrderManagerInterface $orderManager) * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for orders list pagination (1-indexed)") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of orders by page") - * @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") - * @QueryParam(name="status", requirements="\d+", nullable=true, strict=true, description="Filter on order statuses") - * @QueryParam(name="customer", requirements="\d+", nullable=true, strict=true, description="Filter on customer id") + * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for orders list pagination (1-indexed)") + * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of orders by page") + * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") + * @Rest\QueryParam(name="status", requirements="\d+", nullable=true, strict=true, description="Filter on order statuses") + * @Rest\QueryParam(name="customer", requirements="\d+", nullable=true, strict=true, description="Filter on customer id") * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @return \Sonata\DatagridBundle\Pager\PagerInterface + * @return PagerInterface */ public function getOrdersAction(ParamFetcherInterface $paramFetcher) { @@ -86,7 +86,7 @@ public function getOrdersAction(ParamFetcherInterface $paramFetcher) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="order id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Order identifier"} * }, * output={"class"="Sonata\Component\Order\OrderInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -95,7 +95,7 @@ public function getOrdersAction(ParamFetcherInterface $paramFetcher) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -111,7 +111,7 @@ public function getOrderAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="order id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Order identifier"} * }, * output={"class"="Sonata\Component\Order\OrderElementInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -120,7 +120,7 @@ public function getOrderAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -136,7 +136,7 @@ public function getOrderOrderelementsAction($id) * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return OrderInterface */ diff --git a/src/OrderBundle/Resources/config/routing/api.xml b/src/OrderBundle/Resources/config/routing/api.xml index 086b476c1..8c2f9cdb0 100644 --- a/src/OrderBundle/Resources/config/routing/api.xml +++ b/src/OrderBundle/Resources/config/routing/api.xml @@ -1,4 +1,4 @@ - - + + diff --git a/src/OrderBundle/Resources/config/routing/api/order.xml b/src/OrderBundle/Resources/config/routing/api/order.xml new file mode 100644 index 000000000..0e0d48a43 --- /dev/null +++ b/src/OrderBundle/Resources/config/routing/api/order.xml @@ -0,0 +1,12 @@ + + + + json|xml|html + + + json|xml|html + + + json|xml|html + + diff --git a/src/ProductBundle/Controller/Api/ProductController.php b/src/ProductBundle/Controller/Api/ProductController.php index 6f950957e..2f2ebd51b 100644 --- a/src/ProductBundle/Controller/Api/ProductController.php +++ b/src/ProductBundle/Controller/Api/ProductController.php @@ -14,11 +14,7 @@ namespace Sonata\ProductBundle\Controller\Api; use FOS\RestBundle\Context\Context; -use FOS\RestBundle\Controller\Annotations\Post; -use FOS\RestBundle\Controller\Annotations\Put; -use FOS\RestBundle\Controller\Annotations\QueryParam; -use FOS\RestBundle\Controller\Annotations\Route; -use FOS\RestBundle\Controller\Annotations\View; +use FOS\RestBundle\Controller\Annotations as Rest; use FOS\RestBundle\Request\ParamFetcherInterface; use FOS\RestBundle\View\View as FOSRestView; use Nelmio\ApiDocBundle\Annotation\ApiDoc; @@ -31,6 +27,7 @@ use Sonata\Component\Product\ProductCollectionInterface; use Sonata\Component\Product\ProductInterface; use Sonata\Component\Product\ProductManagerInterface; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\FormatterBundle\Formatter\Pool as FormatterPool; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\Request; @@ -82,14 +79,14 @@ public function __construct(ProductManagerInterface $productManager, Pool $produ * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"={"sonata_api_read"}} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for products list pagination (1-indexed)") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of products by page") - * @QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") - * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/disabled products only?") + * @Rest\QueryParam(name="page", requirements="\d+", default="1", description="Page for products list pagination (1-indexed)") + * @Rest\QueryParam(name="count", requirements="\d+", default="10", description="Number of products by page") + * @Rest\QueryParam(name="orderBy", map=true, requirements="ASC|DESC", nullable=true, strict=true, description="Sort specification for the resultset (key is field, value is direction") + * @Rest\QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/disabled products only?") * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * - * @return \Sonata\DatagridBundle\Pager\PagerInterface + * @return PagerInterface */ public function getProductsAction(ParamFetcherInterface $paramFetcher) { @@ -122,7 +119,7 @@ public function getProductsAction(ParamFetcherInterface $paramFetcher) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\Component\Product\ProductInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -131,7 +128,7 @@ public function getProductsAction(ParamFetcherInterface $paramFetcher) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -145,7 +142,7 @@ public function getProductAction($id) /** * Adds a product depending on the product provider. * - * @Post("/{provider}/products") + * @Rest\Post("/{provider}/products") * * @ApiDoc( * resource=true, @@ -158,10 +155,8 @@ public function getProductAction($id) * } * ) * - * @Route(requirements={"provider"="[A-Za-z0-9._]"}) - * - * @param string $provider A product provider name - * @param Request $request A Symfony request + * @param string $provider Product provider name + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -173,11 +168,11 @@ public function postProductAction($provider, Request $request) /** * Updates a product. * - * @Put("/{provider}/products/{id}") + * @Rest\Put("/{provider}/products/{id}") * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product identifier"}, - * {"name"="provider", "dataType"="string", "requirement"="[A-Za-z0-9.]*", "description"="product provider"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"}, + * {"name"="provider", "dataType"="string", "requirement"="[A-Za-z0-9.]*", "description"="Product provider"} * }, * input={"class"="sonata_product_api_form_product", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="Sonata\ProductBundle\Entity\BaseProduct", "groups"={"sonata_api_read"}}, @@ -188,11 +183,9 @@ public function postProductAction($provider, Request $request) * } * ) * - * @Route(requirements={"provider"="[A-Za-z0-9.]*"}) - * - * @param int $id A Product identifier - * @param string $provider A product provider name - * @param Request $request A Symfony request + * @param int $id Product identifier + * @param string $provider Product provider name + * @param Request $request Symfony request * * @return FOSRestView|FormInterface */ @@ -206,7 +199,7 @@ public function putProductAction($id, $provider, Request $request) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product identifier"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * statusCodes={ * 200="Returned when post is successfully deleted", @@ -215,11 +208,11 @@ public function putProductAction($id, $provider, Request $request) * } * ) * - * @param int $id A Product identifier + * @param int $id Product identifier * * @throws NotFoundHttpException * - * @return \FOS\RestBundle\View\View + * @return FOSRestView */ public function deleteProductAction($id) { @@ -240,7 +233,7 @@ public function deleteProductAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\Component\Product\ProductCategoryInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -249,7 +242,7 @@ public function deleteProductAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -265,7 +258,7 @@ public function getProductProductcategoriesAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\ClassificationBundle\Model\CategoryInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -274,7 +267,7 @@ public function getProductProductcategoriesAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -290,7 +283,7 @@ public function getProductCategoriesAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\Component\Product\ProductCollectionInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -299,7 +292,7 @@ public function getProductCategoriesAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -315,7 +308,7 @@ public function getProductProductcollectionsAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\ClassificationBundle\Model\CollectionInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -324,7 +317,7 @@ public function getProductProductcollectionsAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -340,7 +333,7 @@ public function getProductCollectionsAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\Component\Product\DeliveryInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -349,7 +342,7 @@ public function getProductCollectionsAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -365,7 +358,7 @@ public function getProductDeliveriesAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\Component\Product\PackageInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -374,7 +367,7 @@ public function getProductDeliveriesAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -390,7 +383,7 @@ public function getProductPackagesAction($id) * * @ApiDoc( * requirements={ - * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="product id"} + * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="Product identifier"} * }, * output={"class"="Sonata\Component\Product\ProductInterface", "groups"={"sonata_api_read"}}, * statusCodes={ @@ -399,7 +392,7 @@ public function getProductPackagesAction($id) * } * ) * - * @View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) + * @Rest\View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true) * * @param $id * @@ -413,11 +406,11 @@ public function getProductVariationsAction($id) /** * Write a product, this method is used by both POST and PUT action methods. * - * @param string $provider A product provider name + * @param string $provider Product provider name * @param Request $request Symfony request - * @param int|null $id A product identifier + * @param int|null $id Product identifier * - * @return \FOS\RestBundle\View\View|FormInterface + * @return FOSRestView|FormInterface */ protected function handleWriteProduct($provider, $request, $id = null) { @@ -463,11 +456,11 @@ protected function handleWriteProduct($provider, $request, $id = null) } /** - * Retrieves product with id $id or throws an exception if it doesn't exist. + * Retrieves product with identifier $id or throws an exception if it doesn't exist. * * @param $id * - * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @throws NotFoundHttpException * * @return ProductInterface */ diff --git a/src/ProductBundle/Resources/config/routing/api.xml b/src/ProductBundle/Resources/config/routing/api.xml index 75a6f5b82..2a1b228d2 100644 --- a/src/ProductBundle/Resources/config/routing/api.xml +++ b/src/ProductBundle/Resources/config/routing/api.xml @@ -1,4 +1,4 @@ - - + + diff --git a/src/ProductBundle/Resources/config/routing/api/product.xml b/src/ProductBundle/Resources/config/routing/api/product.xml new file mode 100644 index 000000000..46e5a4665 --- /dev/null +++ b/src/ProductBundle/Resources/config/routing/api/product.xml @@ -0,0 +1,41 @@ + + + + json|xml|html + + + json|xml|html + + + json|xml|html + [A-Za-z0-9._] + + + json|xml|html + [A-Za-z0-9._] + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + + + json|xml|html + +