Skip to content

Commit f7c3dbc

Browse files
Merge pull request #1768 from meyerbaptiste/merge_2.2
Merge 2.2
2 parents 191012d + 2ab95de commit f7c3dbc

File tree

22 files changed

+55
-59
lines changed

22 files changed

+55
-59
lines changed

features/bootstrap/GraphqlContext.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Behat\Gherkin\Node\PyStringNode;
1818
use Behatch\Context\RestContext;
1919
use Behatch\HttpCall\Request;
20-
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest;
2120

2221
/**
2322
* Context for GraphQL.
@@ -99,6 +98,6 @@ public function ISendTheGraphqlRequestWithOperation(string $operation)
9998
private function sendGraphqlRequest()
10099
{
101100
$this->request->setHttpHeader('Accept', null);
102-
$this->restContext->iSendARequestTo(HttpFoundationRequest::METHOD_GET, '/graphql?'.http_build_query($this->graphqlRequest));
101+
$this->restContext->iSendARequestTo('GET', '/graphql?'.http_build_query($this->graphqlRequest));
103102
}
104103
}

src/Api/OperationMethodResolverInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
use ApiPlatform\Core\Exception\RuntimeException;
1717

1818
/**
19-
* Resolves the HTTP method associated with an operation.
19+
* Resolves the uppercased HTTP method associated with an operation.
2020
*
2121
* @author Kévin Dunglas <[email protected]>
2222
*/
2323
interface OperationMethodResolverInterface
2424
{
2525
/**
26+
* Resolves the uppercased HTTP method associated with a collection operation.
27+
*
2628
* @param string $resourceClass
2729
* @param string $operationName
2830
*
@@ -33,6 +35,8 @@ interface OperationMethodResolverInterface
3335
public function getCollectionOperationMethod(string $resourceClass, string $operationName): string;
3436

3537
/**
38+
* Resolves the uppercased HTTP method associated with an item operation.
39+
*
3640
* @param string $resourceClass
3741
* @param string $operationName
3842
*

src/Bridge/Doctrine/EventListener/WriteListener.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Core\EventListener\WriteListener as BaseWriteListener;
1717
use Doctrine\Common\Persistence\ManagerRegistry;
1818
use Doctrine\Common\Persistence\ObjectManager;
19-
use Symfony\Component\HttpFoundation\Request;
2019
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2120

2221
/**
@@ -58,10 +57,10 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5857
}
5958

6059
switch ($request->getMethod()) {
61-
case Request::METHOD_POST:
60+
case 'POST':
6261
$objectManager->persist($controllerResult);
6362
break;
64-
case Request::METHOD_DELETE:
63+
case 'DELETE':
6564
$objectManager->remove($controllerResult);
6665
$event->setControllerResult(null);
6766
break;

src/Bridge/FosUser/EventListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Core\Util\RequestAttributesExtractor;
1717
use FOS\UserBundle\Model\UserInterface;
1818
use FOS\UserBundle\Model\UserManagerInterface;
19-
use Symfony\Component\HttpFoundation\Request;
2019
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2120

2221
/**
@@ -52,7 +51,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5251
}
5352

5453
switch ($request->getMethod()) {
55-
case Request::METHOD_DELETE:
54+
case 'DELETE':
5655
$this->userManager->deleteUser($user);
5756
$event->setControllerResult(null);
5857
break;

src/Bridge/NelmioApiDoc/Extractor/AnnotationsProvider/ApiPlatformProvider.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
2525
use Nelmio\ApiDocBundle\Extractor\AnnotationsProviderInterface;
2626
use Psr\Container\ContainerInterface;
27-
use Symfony\Component\HttpFoundation\Request;
2827
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2928

3029
/**
@@ -140,7 +139,7 @@ private function getApiDoc(bool $collection, string $resourceClass, ResourceMeta
140139
$data['output'] = sprintf('%s:%s:%s', ApiPlatformParser::OUT_PREFIX, $resourceClass, $operationName);
141140
}
142141

143-
if ($collection && Request::METHOD_GET === $method) {
142+
if ($collection && 'GET' === $method) {
144143
$resourceFilters = $resourceMetadata->getCollectionOperationAttribute($operationName, 'filters', [], true);
145144

146145
$data['filters'] = [];

src/Bridge/Symfony/Routing/OperationMethodResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function getOperationMethod(string $resourceClass, string $operationName
8989
}
9090

9191
if (null !== $method) {
92-
return $method;
92+
return strtoupper($method);
9393
}
9494

9595
if (null === $routeName = $this->getRouteName($resourceMetadata, $operationName, $operationType)) {

src/Bridge/Symfony/Validator/EventListener/ValidateListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use ApiPlatform\Core\Util\RequestAttributesExtractor;
1919
use ApiPlatform\Core\Validator\EventListener\ValidateListener as MainValidateListener;
2020
use Psr\Container\ContainerInterface;
21-
use Symfony\Component\HttpFoundation\Request;
2221
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2322
use Symfony\Component\Validator\Validator\ValidatorInterface;
2423

@@ -56,7 +55,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event)
5655
$request = $event->getRequest();
5756
if (
5857
$request->isMethodSafe(false)
59-
|| $request->isMethod(Request::METHOD_DELETE)
58+
|| $request->isMethod('DELETE')
6059
|| !($attributes = RequestAttributesExtractor::extractAttributes($request))
6160
|| !$attributes['receive']
6261
) {

src/EventListener/DeserializeListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function onKernelRequest(GetResponseEvent $event)
4949
$request = $event->getRequest();
5050
if (
5151
$request->isMethodSafe(false)
52-
|| $request->isMethod(Request::METHOD_DELETE)
52+
|| $request->isMethod('DELETE')
5353
|| !($attributes = RequestAttributesExtractor::extractAttributes($request))
5454
|| !$attributes['receive']
55-
|| ('' === ($requestContent = $request->getContent()) && $request->isMethod(Request::METHOD_PUT))
55+
|| ('' === ($requestContent = $request->getContent()) && $request->isMethod('PUT'))
5656
) {
5757
return;
5858
}

src/EventListener/ReadListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function onKernelRequest(GetResponseEvent $event)
9393
*/
9494
private function getCollectionData(Request $request, array $attributes, array $context)
9595
{
96-
if ($request->isMethod(Request::METHOD_POST)) {
96+
if ($request->isMethod('POST')) {
9797
return null;
9898
}
9999

src/EventListener/RespondListener.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace ApiPlatform\Core\EventListener;
1515

16-
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Response;
1817
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
1918

@@ -25,8 +24,8 @@
2524
final class RespondListener
2625
{
2726
const METHOD_TO_CODE = [
28-
Request::METHOD_POST => Response::HTTP_CREATED,
29-
Request::METHOD_DELETE => Response::HTTP_NO_CONTENT,
27+
'POST' => Response::HTTP_CREATED,
28+
'DELETE' => Response::HTTP_NO_CONTENT,
3029
];
3130

3231
/**

0 commit comments

Comments
 (0)