Skip to content

Commit

Permalink
Fix for doctrine extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomanhez committed Sep 10, 2020
1 parent 54a5840 commit 4650cdd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
32 changes: 32 additions & 0 deletions src/Sylius/Bundle/ApiBundle/Doctrine/ApiRequestTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Bundle\ApiBundle\Doctrine;

final class ApiRequestTypes
{
const SHOP_GET = 'SHOP_GET';
const SHOP_PATCH = 'SHOP_PATCH';
const SHOP_DELETE = 'SHOP_DELETE';
const SHOP_ADD_ITEM = 'SHOP_ADD_ITEM';
const SHOP_ADDRESS = 'SHOP_ADDRESS';
const SHOP_SELECT_SHIPPING_METHOD = 'SHOP_SELECT_SHIPPING_METHOD';
const SHOP_SELECT_PAYMENT_METHOD = 'SHOP_SELECT_PAYMENT_METHOD';
const SHOP_COMPLETE = 'SHOP_COMPLETE';
const SHOP_REMOVE_ITEM = 'SHOP_REMOVE_ITEM';
const SHOP_CHANGE_QUANTITY = 'SHOP_CHANGE_QUANTITY';

const ADMIN_GET = 'SHOP_GET';
const ADMIN_PATCH = 'SHOP_PATCH';
const ADMIN_DELETE = 'SHOP_DELETE';
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ApiBundle\Context\UserContextInterface;
use Sylius\Bundle\ApiBundle\Doctrine\ApiRequestTypes;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
Expand Down Expand Up @@ -49,7 +50,11 @@ public function applyToItem(
return;
}

if ($operationName !== Request::METHOD_DELETE) {
if (
$operationName !== Request::METHOD_DELETE &&
$operationName !== ApiRequestTypes::SHOP_DELETE &&
$operationName !== ApiRequestTypes::ADMIN_DELETE
) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ApiBundle\Context\UserContextInterface;
use Sylius\Bundle\ApiBundle\Doctrine\ApiRequestTypes;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
Expand Down Expand Up @@ -49,7 +50,11 @@ public function applyToItem(
return;
}

if ($operationName !== Request::METHOD_GET) {
if (
$operationName !== Request::METHOD_GET &&
$operationName !== ApiRequestTypes::SHOP_GET &&
$operationName !== ApiRequestTypes::ADMIN_GET
) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\QueryBuilder;
use Sylius\Bundle\ApiBundle\Context\UserContextInterface;
use Sylius\Bundle\ApiBundle\Doctrine\ApiRequestTypes;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
Expand Down Expand Up @@ -49,7 +50,18 @@ public function applyToItem(
return;
}

if ($operationName !== Request::METHOD_PATCH) {
if (
$operationName !== Request::METHOD_PATCH &&
$operationName !== ApiRequestTypes::SHOP_PATCH &&
$operationName !== ApiRequestTypes::SHOP_ADD_ITEM &&
$operationName !== ApiRequestTypes::SHOP_ADDRESS &&
$operationName !== ApiRequestTypes::SHOP_COMPLETE &&
$operationName !== ApiRequestTypes::SHOP_REMOVE_ITEM &&
$operationName !== ApiRequestTypes::SHOP_SELECT_PAYMENT_METHOD &&
$operationName !== ApiRequestTypes::SHOP_SELECT_SHIPPING_METHOD &&
$operationName !== ApiRequestTypes::SHOP_CHANGE_QUANTITY &&
$operationName !== ApiRequestTypes::ADMIN_PATCH
) {
return;
}

Expand Down

0 comments on commit 4650cdd

Please sign in to comment.