Skip to content

Commit b204609

Browse files
committed
Abstract Operation, rename Operation to HttpOperation
1 parent 7f29458 commit b204609

File tree

69 files changed

+1264
-1341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1264
-1341
lines changed

src/Doctrine/Common/State/LinksHandlerTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
namespace ApiPlatform\Doctrine\Common\State;
1515

1616
use ApiPlatform\Exception\RuntimeException;
17-
use ApiPlatform\Metadata\AbstractOperation;
1817
use ApiPlatform\Metadata\GraphQl\Operation as GraphQlOperation;
18+
use ApiPlatform\Metadata\HttpOperation;
1919
use ApiPlatform\Metadata\Link;
2020
use ApiPlatform\Metadata\Operation;
2121

2222
trait LinksHandlerTrait
2323
{
2424
/**
25-
* @param Operation|GraphQlOperation $operation
25+
* @param HttpOperation|GraphQlOperation $operation
2626
*
2727
* @return Link[]
2828
*/
29-
private function getLinks(string $resourceClass, AbstractOperation $operation, array $context): array
29+
private function getLinks(string $resourceClass, Operation $operation, array $context): array
3030
{
3131
$links = ($operation instanceof GraphQlOperation ? $operation->getLinks() : $operation->getUriVariables()) ?? [];
3232

src/Doctrine/Common/State/PersistProcessor.php

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

1414
namespace ApiPlatform\Doctrine\Common\State;
1515

16-
use ApiPlatform\Metadata\AbstractOperation;
16+
use ApiPlatform\Metadata\Operation;
1717
use ApiPlatform\State\ProcessorInterface;
1818
use ApiPlatform\Util\ClassInfoTrait;
1919
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
@@ -32,7 +32,7 @@ public function __construct(ManagerRegistry $managerRegistry)
3232
$this->managerRegistry = $managerRegistry;
3333
}
3434

35-
public function process($data, AbstractOperation $operation, array $uriVariables = [], array $context = [])
35+
public function process($data, Operation $operation, array $uriVariables = [], array $context = [])
3636
{
3737
if (!$manager = $this->getManager($data)) {
3838
return $data;

src/Doctrine/Common/State/RemoveProcessor.php

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

1414
namespace ApiPlatform\Doctrine\Common\State;
1515

16-
use ApiPlatform\Metadata\AbstractOperation;
16+
use ApiPlatform\Metadata\Operation;
1717
use ApiPlatform\State\ProcessorInterface;
1818
use ApiPlatform\Util\ClassInfoTrait;
1919
use Doctrine\Persistence\ManagerRegistry;
@@ -30,7 +30,7 @@ public function __construct(ManagerRegistry $managerRegistry)
3030
$this->managerRegistry = $managerRegistry;
3131
}
3232

33-
public function process($data, AbstractOperation $operation, array $uriVariables = [], array $context = [])
33+
public function process($data, Operation $operation, array $uriVariables = [], array $context = [])
3434
{
3535
if (!$manager = $this->getManager($data)) {
3636
return;

src/Doctrine/Odm/State/CollectionProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use ApiPlatform\Doctrine\Odm\Extension\AggregationResultCollectionExtensionInterface;
1818
use ApiPlatform\Exception\OperationNotFoundException;
1919
use ApiPlatform\Exception\RuntimeException;
20-
use ApiPlatform\Metadata\AbstractOperation;
20+
use ApiPlatform\Metadata\Operation;
2121
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2222
use ApiPlatform\State\ProviderInterface;
2323
use Doctrine\ODM\MongoDB\DocumentManager;
@@ -46,7 +46,7 @@ public function __construct(ResourceMetadataCollectionFactoryInterface $resource
4646
$this->collectionExtensions = $collectionExtensions;
4747
}
4848

49-
public function provide(AbstractOperation $operation, array $uriVariables = [], array $context = [])
49+
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
5050
{
5151
$resourceClass = $operation->getClass();
5252
/** @var DocumentManager $manager */

src/Doctrine/Odm/State/ItemProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use ApiPlatform\Doctrine\Odm\Extension\AggregationItemExtensionInterface;
1717
use ApiPlatform\Doctrine\Odm\Extension\AggregationResultItemExtensionInterface;
1818
use ApiPlatform\Exception\RuntimeException;
19-
use ApiPlatform\Metadata\AbstractOperation;
19+
use ApiPlatform\Metadata\Operation;
2020
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2121
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
2222
use ApiPlatform\State\ProviderInterface;
@@ -49,7 +49,7 @@ public function __construct(ResourceMetadataCollectionFactoryInterface $resource
4949
$this->itemExtensions = $itemExtensions;
5050
}
5151

52-
public function provide(AbstractOperation $operation, array $uriVariables = [], array $context = [])
52+
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
5353
{
5454
$resourceClass = $operation->getClass();
5555
/** @var DocumentManager $manager */

src/Doctrine/Orm/Extension/FilterEagerLoadingExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use ApiPlatform\Exception\InvalidArgumentException;
2222
use ApiPlatform\Exception\OperationNotFoundException;
2323
use ApiPlatform\Metadata\GraphQl\Operation as GraphQlOperation;
24-
use ApiPlatform\Metadata\Operation;
24+
use ApiPlatform\Metadata\HttpOperation;
2525
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2626
use Doctrine\ORM\Query\Expr\Join;
2727
use Doctrine\ORM\QueryBuilder;
@@ -58,7 +58,7 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
5858

5959
$em = $queryBuilder->getEntityManager();
6060
$classMetadata = $em->getClassMetadata($resourceClass);
61-
/** @var Operation|GraphQlOperation|null */
61+
/** @var HttpOperation|GraphQlOperation|null */
6262
$operation = null;
6363
$forceEager = $this->forceEager;
6464

src/Doctrine/Orm/Metadata/Resource/DoctrineOrmResourceCollectionMetadataFactory.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
use ApiPlatform\Doctrine\Common\State\RemoveProcessor;
1818
use ApiPlatform\Doctrine\Orm\State\CollectionProvider;
1919
use ApiPlatform\Doctrine\Orm\State\ItemProvider;
20-
use ApiPlatform\Metadata\AbstractOperation;
2120
use ApiPlatform\Metadata\CollectionOperationInterface;
2221
use ApiPlatform\Metadata\DeleteOperationInterface;
22+
use ApiPlatform\Metadata\Operation;
2323
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2424
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
25-
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\AttributeResource;
2625
use Doctrine\ORM\EntityManagerInterface;
2726
use Doctrine\Persistence\ManagerRegistry;
2827

@@ -86,7 +85,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
8685
return $resourceMetadataCollection;
8786
}
8887

89-
private function addDefaults($operation): AbstractOperation
88+
private function addDefaults($operation): Operation
9089
{
9190
if (null === $operation->getProvider()) {
9291
$operation = $operation->withProvider($this->getProvider($operation));
@@ -99,7 +98,7 @@ private function addDefaults($operation): AbstractOperation
9998
return $operation;
10099
}
101100

102-
private function getProvider(AbstractOperation $operation): string
101+
private function getProvider(Operation $operation): string
103102
{
104103
if ($operation instanceof CollectionOperationInterface) {
105104
return CollectionProvider::class;
@@ -108,7 +107,7 @@ private function getProvider(AbstractOperation $operation): string
108107
return ItemProvider::class;
109108
}
110109

111-
private function getProcessor(AbstractOperation $operation): string
110+
private function getProcessor(Operation $operation): string
112111
{
113112
if ($operation instanceof DeleteOperationInterface) {
114113
return RemoveProcessor::class;

src/Doctrine/Orm/State/CollectionProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use ApiPlatform\Doctrine\Orm\Extension\QueryResultCollectionExtensionInterface;
1818
use ApiPlatform\Doctrine\Orm\Util\QueryNameGenerator;
1919
use ApiPlatform\Exception\RuntimeException;
20-
use ApiPlatform\Metadata\AbstractOperation;
20+
use ApiPlatform\Metadata\Operation;
2121
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2222
use ApiPlatform\State\ProviderInterface;
2323
use Doctrine\ORM\EntityManagerInterface;
@@ -48,7 +48,7 @@ public function __construct(ResourceMetadataCollectionFactoryInterface $resource
4848
$this->collectionExtensions = $collectionExtensions;
4949
}
5050

51-
public function provide(AbstractOperation $operation, array $uriVariables = [], array $context = [])
51+
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
5252
{
5353
$resourceClass = $operation->getClass();
5454
/** @var EntityManagerInterface $manager */

src/Doctrine/Orm/State/ItemProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use ApiPlatform\Doctrine\Orm\Extension\QueryResultItemExtensionInterface;
1818
use ApiPlatform\Doctrine\Orm\Util\QueryNameGenerator;
1919
use ApiPlatform\Exception\RuntimeException;
20-
use ApiPlatform\Metadata\AbstractOperation;
20+
use ApiPlatform\Metadata\Operation;
2121
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2222
use ApiPlatform\State\ProviderInterface;
2323
use Doctrine\ORM\EntityManagerInterface;
@@ -48,7 +48,7 @@ public function __construct(ResourceMetadataCollectionFactoryInterface $resource
4848
$this->itemExtensions = $itemExtensions;
4949
}
5050

51-
public function provide(AbstractOperation $operation, array $uriVariables = [], array $context = [])
51+
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
5252
{
5353
$resourceClass = $operation->getClass();
5454
/** @var EntityManagerInterface $manager */

src/Doctrine/Orm/State/LinksHandlerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
use ApiPlatform\Doctrine\Common\State\LinksHandlerTrait as CommonLinksHandlerTrait;
1717
use ApiPlatform\Doctrine\Orm\Util\QueryNameGenerator;
18-
use ApiPlatform\Metadata\AbstractOperation;
18+
use ApiPlatform\Metadata\Operation;
1919
use Doctrine\ORM\Mapping\ClassMetadataInfo;
2020
use Doctrine\ORM\QueryBuilder;
2121

2222
trait LinksHandlerTrait
2323
{
2424
use CommonLinksHandlerTrait;
2525

26-
private function handleLinks(QueryBuilder $queryBuilder, array $identifiers, QueryNameGenerator $queryNameGenerator, array $context, string $resourceClass, AbstractOperation $operation): void
26+
private function handleLinks(QueryBuilder $queryBuilder, array $identifiers, QueryNameGenerator $queryNameGenerator, array $context, string $resourceClass, Operation $operation): void
2727
{
2828
if (!$identifiers) {
2929
return;

src/Elasticsearch/State/CollectionProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use ApiPlatform\Elasticsearch\Extension\RequestBodySearchCollectionExtensionInterface;
1717
use ApiPlatform\Elasticsearch\Metadata\Document\Factory\DocumentMetadataFactoryInterface;
1818
use ApiPlatform\Elasticsearch\Paginator;
19-
use ApiPlatform\Metadata\AbstractOperation;
19+
use ApiPlatform\Metadata\Operation;
2020
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2121
use ApiPlatform\State\Pagination\Pagination;
2222
use ApiPlatform\State\ProviderInterface;
@@ -58,7 +58,7 @@ public function __construct(Client $client, DocumentMetadataFactoryInterface $do
5858
/**
5959
* {@inheritdoc}
6060
*/
61-
public function provide(AbstractOperation $operation, array $uriVariables = [], array $context = [])
61+
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
6262
{
6363
$resourceClass = $operation->getClass();
6464
$documentMetadata = $this->documentMetadataFactory->create($resourceClass);

src/Elasticsearch/State/ItemProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use ApiPlatform\Elasticsearch\Metadata\Document\Factory\DocumentMetadataFactoryInterface;
1717
use ApiPlatform\Elasticsearch\Serializer\DocumentNormalizer;
18-
use ApiPlatform\Metadata\AbstractOperation;
18+
use ApiPlatform\Metadata\Operation;
1919
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
2020
use ApiPlatform\State\ProviderInterface;
2121
use Elasticsearch\Client;
@@ -49,7 +49,7 @@ public function __construct(Client $client, DocumentMetadataFactoryInterface $do
4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function provide(AbstractOperation $operation, array $uriVariables = [], array $context = [])
52+
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
5353
{
5454
$resourceClass = $operation->getClass();
5555
$documentMetadata = $this->documentMetadataFactory->create($resourceClass);

src/GraphQl/Type/FieldsBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use ApiPlatform\Metadata\GraphQl\Mutation;
2020
use ApiPlatform\Metadata\GraphQl\Operation;
2121
use ApiPlatform\Metadata\GraphQl\Subscription;
22-
use ApiPlatform\Metadata\Operation as ApiOperation;
22+
use ApiPlatform\Metadata\HttpOperation as ApiOperation;
2323
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2424
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2525
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use ApiPlatform\Metadata\ApiProperty;
3030
use ApiPlatform\Metadata\ApiResource;
3131
use ApiPlatform\Metadata\CollectionOperationInterface;
32-
use ApiPlatform\Metadata\Operation;
32+
use ApiPlatform\Metadata\HttpOperation;
3333
use ApiPlatform\Metadata\Post;
3434
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
3535
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
@@ -376,12 +376,12 @@ private function getHydraOperations(string $resourceClass, $resourceMetadata, st
376376
*
377377
* @param ResourceMetadata|ApiResource $resourceMetadata
378378
* @param SubresourceMetadata $subresourceMetadata
379-
* @param array|Operation $operation
379+
* @param array|HttpOperation $operation
380380
*/
381381
private function getHydraOperation(string $resourceClass, $resourceMetadata, string $operationName, $operation, string $prefixedShortName, ?string $operationType = null, SubresourceMetadata $subresourceMetadata = null): array
382382
{
383-
if ($operation instanceof Operation) {
384-
$method = $operation->getMethod() ?: Operation::METHOD_GET;
383+
if ($operation instanceof HttpOperation) {
384+
$method = $operation->getMethod() ?: HttpOperation::METHOD_GET;
385385
} elseif ($this->operationMethodResolver) {
386386
if (OperationType::COLLECTION === $operationType) {
387387
$method = $this->operationMethodResolver->getCollectionOperationMethod($resourceClass, $operationName);
@@ -394,12 +394,12 @@ private function getHydraOperation(string $resourceClass, $resourceMetadata, str
394394
$method = $resourceMetadata->getTypedOperationAttribute($operationType, $operationName, 'method', 'GET');
395395
}
396396

397-
$hydraOperation = $operation instanceof Operation ? ($operation->getHydraContext() ?? []) : ($operation['hydra_context'] ?? []);
398-
if ($operation instanceof Operation ? $operation->getDeprecationReason() : $resourceMetadata->getTypedOperationAttribute($operationType, $operationName, 'deprecation_reason', null, true)) {
397+
$hydraOperation = $operation instanceof HttpOperation ? ($operation->getHydraContext() ?? []) : ($operation['hydra_context'] ?? []);
398+
if ($operation instanceof HttpOperation ? $operation->getDeprecationReason() : $resourceMetadata->getTypedOperationAttribute($operationType, $operationName, 'deprecation_reason', null, true)) {
399399
$hydraOperation['owl:deprecated'] = true;
400400
}
401401

402-
if ($operation instanceof Operation) {
402+
if ($operation instanceof HttpOperation) {
403403
$shortName = $operation->getShortName();
404404
$inputMetadata = $operation->getInput() ?? [];
405405
$outputMetadata = $operation->getOutput() ?? [];

src/JsonLd/ContextBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
2020
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
2121
use ApiPlatform\Metadata\ApiProperty;
22-
use ApiPlatform\Metadata\Operation;
22+
use ApiPlatform\Metadata\HttpOperation;
2323
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2424
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2525
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
@@ -204,7 +204,7 @@ public function getAnonymousResourceContext($object, array $context = [], int $r
204204
return $jsonLdContext;
205205
}
206206

207-
private function getResourceContextWithShortname(string $resourceClass, int $referenceType, string $shortName, ?Operation $operation = null): array
207+
private function getResourceContextWithShortname(string $resourceClass, int $referenceType, string $shortName, ?HttpOperation $operation = null): array
208208
{
209209
$context = $this->getBaseContext($referenceType);
210210
if ($this->propertyMetadataFactory instanceof LegacyPropertyMetadataFactoryInterface) {

src/JsonSchema/SchemaFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
2323
use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer;
2424
use ApiPlatform\Metadata\ApiProperty;
25-
use ApiPlatform\Metadata\Operation;
25+
use ApiPlatform\Metadata\HttpOperation;
2626
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2727
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2828
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
@@ -379,7 +379,7 @@ private function getSerializerContext($resourceMetadata, string $type = Schema::
379379
}
380380

381381
/**
382-
* @param Operation|ResourceMetadata|null $resourceMetadata
382+
* @param HttpOperation|ResourceMetadata|null $resourceMetadata
383383
*/
384384
private function getValidationGroups($resourceMetadata, ?string $operationType, ?string $operationName): array
385385
{
@@ -401,7 +401,7 @@ private function getValidationGroups($resourceMetadata, ?string $operationType,
401401
/**
402402
* Gets the options for the property name collection / property metadata factories.
403403
*/
404-
private function getFactoryOptions(array $serializerContext, array $validationGroups, ?string $operationType, ?string $operationName, ?Operation $operation = null): array
404+
private function getFactoryOptions(array $serializerContext, array $validationGroups, ?string $operationType, ?string $operationName, ?HttpOperation $operation = null): array
405405
{
406406
$options = [
407407
/* @see https://github.com/symfony/symfony/blob/v5.1.0/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php */

0 commit comments

Comments
 (0)