diff --git a/src/DataProvider/CountryCollectionDataProvider.php b/src/DataProvider/CountryCollectionDataProvider.php index 0a73afc6..99a4fa36 100644 --- a/src/DataProvider/CountryCollectionDataProvider.php +++ b/src/DataProvider/CountryCollectionDataProvider.php @@ -10,6 +10,7 @@ namespace BitBag\SyliusGraphqlPlugin\DataProvider; +use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\ContextAwareQueryCollectionExtensionInterface; use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\ContextAwareQueryResultCollectionExtensionInterface; use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInterface; use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryResultCollectionExtensionInterface; @@ -54,7 +55,11 @@ public function getCollection(string $resourceClass, string $operationName = nul /** @var QueryCollectionExtensionInterface $extension */ foreach ($this->collectionExtensions as $extension) { - $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName); + if ($extension instanceof ContextAwareQueryCollectionExtensionInterface) { + $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName, $context); + } else { + $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName); + } if ($extension instanceof QueryResultCollectionExtensionInterface && $extension->supportsResult($resourceClass, $operationName)) { return $extension->getResult($queryBuilder); diff --git a/src/DataProvider/ShippingMethodCollectionDataProvider.php b/src/DataProvider/ShippingMethodCollectionDataProvider.php index 155ff74b..f02737a0 100644 --- a/src/DataProvider/ShippingMethodCollectionDataProvider.php +++ b/src/DataProvider/ShippingMethodCollectionDataProvider.php @@ -53,9 +53,13 @@ public function getCollection(string $resourceClass, string $operationName = nul { $queryBuilder = $this->shippingMethodRepository->createQueryBuilder('o'); - /** @var ContextAwareQueryCollectionExtensionInterface $extension */ + /** @var QueryCollectionExtensionInterface $extension */ foreach ($this->collectionExtensions as $extension) { - $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName, $context); + if ($extension instanceof ContextAwareQueryCollectionExtensionInterface) { + $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName, $context); + } else { + $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName); + } if ($extension instanceof QueryResultCollectionExtensionInterface && $extension->supportsResult($resourceClass, $operationName)) { return $extension->getResult($queryBuilder); diff --git a/src/DataProvider/TaxonCollectionDataProvider.php b/src/DataProvider/TaxonCollectionDataProvider.php index 46eddc3f..142d0504 100644 --- a/src/DataProvider/TaxonCollectionDataProvider.php +++ b/src/DataProvider/TaxonCollectionDataProvider.php @@ -10,6 +10,7 @@ namespace BitBag\SyliusGraphqlPlugin\DataProvider; +use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\ContextAwareQueryCollectionExtensionInterface; use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\PaginationExtension; use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInterface; use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryResultCollectionExtensionInterface; @@ -74,7 +75,11 @@ public function getCollection(string $resourceClass, string $operationName = nul /** @var QueryCollectionExtensionInterface $extension */ foreach ($this->collectionExtensions as $extension) { - $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName); + if ($extension instanceof ContextAwareQueryCollectionExtensionInterface) { + $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName, $context); + } else { + $extension->applyToCollection($queryBuilder, $this->queryNameGenerator, $resourceClass, $operationName); + } if ($extension instanceof QueryResultCollectionExtensionInterface && $extension->supportsResult($resourceClass, $operationName)) { return $extension->getResult($queryBuilder); diff --git a/src/Metadata/Resource/Factory/InterfaceExtractorResourceMetadataFactory.php b/src/Metadata/Resource/Factory/InterfaceExtractorResourceMetadataFactory.php index e05c48d8..38c8df5f 100644 --- a/src/Metadata/Resource/Factory/InterfaceExtractorResourceMetadataFactory.php +++ b/src/Metadata/Resource/Factory/InterfaceExtractorResourceMetadataFactory.php @@ -18,7 +18,7 @@ /** @experimental */ final class InterfaceExtractorResourceMetadataFactory implements ResourceMetadataFactoryInterface { - const GRAPHQL_PROPERTIES = [ + public const GRAPHQL_PROPERTIES = [ 'shortName', 'description', 'iri', @@ -26,7 +26,7 @@ final class InterfaceExtractorResourceMetadataFactory implements ResourceMetadat 'collectionOperations', 'subresourceOperations', 'graphql', - 'attributes' + 'attributes', ]; private ?ResourceMetadataFactoryInterface $decoratedResourceMetadataFactory; @@ -48,7 +48,8 @@ public function create(string $resourceClass): ResourceMetadata if (null !== $this->decoratedResourceMetadataFactory) { try { $parentResourceMetadata = $this->decoratedResourceMetadataFactory->create($resourceClass); - } catch (ResourceClassNotFoundException $resourceNotFoundException) {} + } catch (ResourceClassNotFoundException $resourceNotFoundException) { + } } if (null !== $parentResourceMetadata) { diff --git a/src/Metadata/Resource/Factory/ReflectionClassResourceMetadataFactory.php b/src/Metadata/Resource/Factory/ReflectionClassResourceMetadataFactory.php index 97e6e2cc..77e3124a 100644 --- a/src/Metadata/Resource/Factory/ReflectionClassResourceMetadataFactory.php +++ b/src/Metadata/Resource/Factory/ReflectionClassResourceMetadataFactory.php @@ -36,7 +36,8 @@ public function create(string $resourceClass): ResourceMetadata if (null !== $this->decoratedResourceMetadataFactory) { try { $parentResourceMetadata = $this->decoratedResourceMetadataFactory->create($resourceClass); - } catch (ResourceClassNotFoundException $resourceNotFoundException) {} + } catch (ResourceClassNotFoundException $resourceNotFoundException) { + } } if (null !== $parentResourceMetadata) {