From d96f577a348e6dd44d826975e00c894c8a7d1747 Mon Sep 17 00:00:00 2001 From: mattamon Date: Wed, 24 Apr 2024 15:03:39 +0200 Subject: [PATCH] Cleanup --- .../Api/Assets/CollectionController.php | 4 +-- .../Api/DataObjects/CollectionController.php | 4 +-- src/Exception/AbstractApiException.php | 2 +- src/Exception/ApiExceptionInterface.php | 27 ------------------- .../Filter/ElementParametersInterface.php | 2 +- src/Security/Voter/AuthorizationVoter.php | 2 +- .../Voter/PublicAuthorizationVoter.php | 4 +-- src/Util/Traits/PaginatedResponseTrait.php | 4 +-- .../Traits}/PublicTranslationTrait.php | 2 +- .../Trait => Util/Traits}/RequestTrait.php | 2 +- 10 files changed, 13 insertions(+), 40 deletions(-) delete mode 100644 src/Exception/ApiExceptionInterface.php rename src/{Security/Trait => Util/Traits}/PublicTranslationTrait.php (96%) rename src/{Security/Trait => Util/Traits}/RequestTrait.php (96%) diff --git a/src/Controller/Api/Assets/CollectionController.php b/src/Controller/Api/Assets/CollectionController.php index 680a5f733..b59d0f06e 100644 --- a/src/Controller/Api/Assets/CollectionController.php +++ b/src/Controller/Api/Assets/CollectionController.php @@ -56,7 +56,7 @@ final class CollectionController extends AbstractApiController public function __construct( SerializerInterface $serializer, private readonly AssetSearchServiceInterface $assetSearchService, - private readonly FilterServiceProviderInterface $filterServiceFactory + private readonly FilterServiceProviderInterface $filterServiceProvider ) { parent::__construct($serializer); } @@ -93,7 +93,7 @@ public function __construct( #[UnprocessableContentResponse] public function getAssets(#[MapQueryString] ElementParameters $parameters): JsonResponse { - $filterService = $this->filterServiceFactory->create(OpenSearchFilterInterface::SERVICE_TYPE); + $filterService = $this->filterServiceProvider->create(OpenSearchFilterInterface::SERVICE_TYPE); $assetQuery = $filterService->applyFilters( $parameters, diff --git a/src/Controller/Api/DataObjects/CollectionController.php b/src/Controller/Api/DataObjects/CollectionController.php index d4198babf..3adb65def 100644 --- a/src/Controller/Api/DataObjects/CollectionController.php +++ b/src/Controller/Api/DataObjects/CollectionController.php @@ -54,7 +54,7 @@ final class CollectionController extends AbstractApiController public function __construct( SerializerInterface $serializer, private readonly DataObjectSearchServiceInterface $dataObjectSearchService, - private readonly FilterServiceProviderInterface $filterServiceFactory + private readonly FilterServiceProviderInterface $filterServiceProvider ) { parent::__construct($serializer); } @@ -92,7 +92,7 @@ public function __construct( #[UnprocessableContentResponse] public function getDataObjects(#[MapQueryString] DataObjectParameters $parameters): JsonResponse { - $filterService = $this->filterServiceFactory->create(OpenSearchFilterInterface::SERVICE_TYPE); + $filterService = $this->filterServiceProvider->create(OpenSearchFilterInterface::SERVICE_TYPE); $dataObjectQuery = $filterService->applyFilters($parameters, 'dataObject'); diff --git a/src/Exception/AbstractApiException.php b/src/Exception/AbstractApiException.php index 1f326d5b8..d975a061b 100644 --- a/src/Exception/AbstractApiException.php +++ b/src/Exception/AbstractApiException.php @@ -18,6 +18,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException; -abstract class AbstractApiException extends HttpException implements ApiExceptionInterface +abstract class AbstractApiException extends HttpException { } diff --git a/src/Exception/ApiExceptionInterface.php b/src/Exception/ApiExceptionInterface.php deleted file mode 100644 index 49c23d4d2..000000000 --- a/src/Exception/ApiExceptionInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -serialize(new Collection($totalItems, $data), 'json'); + $serialized = $serializer->serialize(new Collection($totalItems, $items), 'json'); return new JsonResponse($serialized, 200, [self::HEADER_TOTAL_ITEMS => $totalItems], true); } diff --git a/src/Security/Trait/PublicTranslationTrait.php b/src/Util/Traits/PublicTranslationTrait.php similarity index 96% rename from src/Security/Trait/PublicTranslationTrait.php rename to src/Util/Traits/PublicTranslationTrait.php index 566dac245..47c44ee63 100644 --- a/src/Security/Trait/PublicTranslationTrait.php +++ b/src/Util/Traits/PublicTranslationTrait.php @@ -14,7 +14,7 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\StudioApiBundle\Security\Trait; +namespace Pimcore\Bundle\StudioApiBundle\Util\Traits; use Pimcore\Bundle\StudioApiBundle\Exception\NonPublicTranslationException; use Pimcore\Bundle\StudioApiBundle\Util\Constants\PublicTranslations; diff --git a/src/Security/Trait/RequestTrait.php b/src/Util/Traits/RequestTrait.php similarity index 96% rename from src/Security/Trait/RequestTrait.php rename to src/Util/Traits/RequestTrait.php index 100d83b69..3128a9678 100644 --- a/src/Security/Trait/RequestTrait.php +++ b/src/Util/Traits/RequestTrait.php @@ -14,7 +14,7 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\StudioApiBundle\Security\Trait; +namespace Pimcore\Bundle\StudioApiBundle\Util\Traits; use Pimcore\Bundle\StudioApiBundle\Exception\NoRequestException; use Pimcore\Bundle\StudioApiBundle\Exception\NotAuthorizedException;