From b7ef53cf52d95177c93e9fe63928ef078e0171dc Mon Sep 17 00:00:00 2001 From: Herbert Roth Date: Thu, 18 Apr 2024 17:20:21 +0200 Subject: [PATCH 1/9] Try to use interfaces. --- src/Controller/Api/Assets/CollectionController.php | 1 - src/Service/AssetSearchServiceInterface.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Controller/Api/Assets/CollectionController.php b/src/Controller/Api/Assets/CollectionController.php index dac059fd8..9a3e57fcf 100644 --- a/src/Controller/Api/Assets/CollectionController.php +++ b/src/Controller/Api/Assets/CollectionController.php @@ -85,7 +85,6 @@ public function __construct( #[UnauthorizedResponse] public function getAssets(#[MapQueryString] Parameters $parameters): JsonResponse { - /** @var AssetQuery $assetQuery */ $assetQuery = $this->filterService->applyFilters( $parameters, FilterServiceInterface::TYPE_ASSET diff --git a/src/Service/AssetSearchServiceInterface.php b/src/Service/AssetSearchServiceInterface.php index 482a74f4c..5a49605a5 100644 --- a/src/Service/AssetSearchServiceInterface.php +++ b/src/Service/AssetSearchServiceInterface.php @@ -25,11 +25,11 @@ use Pimcore\Bundle\StudioApiBundle\Response\Asset\Text; use Pimcore\Bundle\StudioApiBundle\Response\Asset\Unknown; use Pimcore\Bundle\StudioApiBundle\Response\Asset\Video; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; +use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; interface AssetSearchServiceInterface { - public function searchAssets(AssetQuery $assetQuery): AssetSearchResult; + public function searchAssets(QueryInterface $assetQuery): AssetSearchResult; public function getAssetById(int $id): Asset|Archive|Audio|Document|Folder|Image|Text|Unknown|Video|null; } From e3728c59597d708c5862d668395d30bd21643c9d Mon Sep 17 00:00:00 2001 From: herbertroth Date: Thu, 18 Apr 2024 15:22:23 +0000 Subject: [PATCH 2/9] Apply php-cs-fixer changes --- src/Controller/Api/Assets/CollectionController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Controller/Api/Assets/CollectionController.php b/src/Controller/Api/Assets/CollectionController.php index 9a3e57fcf..b48b65e43 100644 --- a/src/Controller/Api/Assets/CollectionController.php +++ b/src/Controller/Api/Assets/CollectionController.php @@ -36,7 +36,6 @@ use Pimcore\Bundle\StudioApiBundle\Request\Query\Filter\Parameters; use Pimcore\Bundle\StudioApiBundle\Service\AssetSearchServiceInterface; use Pimcore\Bundle\StudioApiBundle\Service\Filter\FilterServiceInterface; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; use Symfony\Component\Routing\Attribute\Route; From c90dd2d19877b3541fb131f8dd230b01d52d6fe0 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 07:53:55 +0200 Subject: [PATCH 3/9] Update methods to interfaces --- src/Controller/Api/DataObjects/CollectionController.php | 1 - src/Service/AssetSearchService.php | 3 ++- src/Service/DataObjectSearchService.php | 3 ++- src/Service/DataObjectSearchServiceInterface.php | 3 ++- src/Service/GenericData/AssetSearchAdapterInterface.php | 3 ++- src/Service/GenericData/DataObjectSearchAdapterInterface.php | 3 ++- src/Service/GenericData/V1/AssetSearchAdapter.php | 2 +- src/Service/GenericData/V1/DataObjectSearchAdapter.php | 2 +- src/Service/GenericData/V1/QueryInterface.php | 3 ++- 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Controller/Api/DataObjects/CollectionController.php b/src/Controller/Api/DataObjects/CollectionController.php index 60bdd5ce7..4d1f2a786 100644 --- a/src/Controller/Api/DataObjects/CollectionController.php +++ b/src/Controller/Api/DataObjects/CollectionController.php @@ -85,7 +85,6 @@ public function __construct( public function getDataObjects(#[MapQueryString] DataObjectParameters $parameters): JsonResponse { - /** @var DataObjectQuery $dataObjectQuery */ $dataObjectQuery = $this->filterService->applyFilters($parameters, 'dataObject'); $result = $this->dataObjectSearchService->searchDataObjects($dataObjectQuery); diff --git a/src/Service/AssetSearchService.php b/src/Service/AssetSearchService.php index 47b39e25a..680a64f7c 100644 --- a/src/Service/AssetSearchService.php +++ b/src/Service/AssetSearchService.php @@ -27,6 +27,7 @@ use Pimcore\Bundle\StudioApiBundle\Response\Asset\Video; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\AssetSearchAdapterInterface; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; +use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; final readonly class AssetSearchService implements AssetSearchServiceInterface { @@ -34,7 +35,7 @@ public function __construct(private AssetSearchAdapterInterface $assetSearchAdap { } - public function searchAssets(AssetQuery $assetQuery): AssetSearchResult + public function searchAssets(QueryInterface $assetQuery): AssetSearchResult { return $this->assetSearchAdapter->searchAssets($assetQuery); } diff --git a/src/Service/DataObjectSearchService.php b/src/Service/DataObjectSearchService.php index aa7ab6625..7d55a17af 100644 --- a/src/Service/DataObjectSearchService.php +++ b/src/Service/DataObjectSearchService.php @@ -18,6 +18,7 @@ use Pimcore\Bundle\StudioApiBundle\Service\GenericData\DataObjectSearchAdapterInterface; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; +use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; use Pimcore\Model\DataObject\Concrete; final readonly class DataObjectSearchService implements DataObjectSearchServiceInterface @@ -26,7 +27,7 @@ public function __construct(private DataObjectSearchAdapterInterface $dataObject { } - public function searchDataObjects(DataObjectQuery $dataObjectQuery): DataObjectSearchResult + public function searchDataObjects(QueryInterface $dataObjectQuery): DataObjectSearchResult { return $this->dataObjectSearchAdapter->searchDataObjects($dataObjectQuery); } diff --git a/src/Service/DataObjectSearchServiceInterface.php b/src/Service/DataObjectSearchServiceInterface.php index 018181607..86bc8f174 100644 --- a/src/Service/DataObjectSearchServiceInterface.php +++ b/src/Service/DataObjectSearchServiceInterface.php @@ -17,11 +17,12 @@ namespace Pimcore\Bundle\StudioApiBundle\Service; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; +use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; use Pimcore\Model\DataObject\Concrete; interface DataObjectSearchServiceInterface { - public function searchDataObjects(DataObjectQuery $dataObjectQuery): DataObjectSearchResult; + public function searchDataObjects(QueryInterface $dataObjectQuery): DataObjectSearchResult; public function getDataObjectById(int $id): Concrete|null; } diff --git a/src/Service/GenericData/AssetSearchAdapterInterface.php b/src/Service/GenericData/AssetSearchAdapterInterface.php index e2de598a7..5770edd90 100644 --- a/src/Service/GenericData/AssetSearchAdapterInterface.php +++ b/src/Service/GenericData/AssetSearchAdapterInterface.php @@ -19,10 +19,11 @@ use Pimcore\Bundle\StudioApiBundle\Response\Asset; use Pimcore\Bundle\StudioApiBundle\Service\AssetSearchResult; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; +use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; interface AssetSearchAdapterInterface { - public function searchAssets(AssetQuery $assetQuery): AssetSearchResult; + public function searchAssets(QueryInterface $assetQuery): AssetSearchResult; public function getAssetById(int $id): ?Asset; } diff --git a/src/Service/GenericData/DataObjectSearchAdapterInterface.php b/src/Service/GenericData/DataObjectSearchAdapterInterface.php index 8b64f8d13..072626708 100644 --- a/src/Service/GenericData/DataObjectSearchAdapterInterface.php +++ b/src/Service/GenericData/DataObjectSearchAdapterInterface.php @@ -18,11 +18,12 @@ use Pimcore\Bundle\StudioApiBundle\Service\DataObjectSearchResult; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; +use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; use Pimcore\Model\Element\ElementInterface; interface DataObjectSearchAdapterInterface { - public function searchDataObjects(DataObjectQuery $dataObjectQuery): DataObjectSearchResult; + public function searchDataObjects(QueryInterface $dataObjectQuery): DataObjectSearchResult; public function getDataObjectById(int $id): ?ElementInterface; } diff --git a/src/Service/GenericData/V1/AssetSearchAdapter.php b/src/Service/GenericData/V1/AssetSearchAdapter.php index def594701..6ab1462cc 100644 --- a/src/Service/GenericData/V1/AssetSearchAdapter.php +++ b/src/Service/GenericData/V1/AssetSearchAdapter.php @@ -34,7 +34,7 @@ public function __construct( /** * @throws Exception */ - public function searchAssets(AssetQuery $assetQuery): AssetSearchResult + public function searchAssets(QueryInterface $assetQuery): AssetSearchResult { $searchResult = $this->searchService->search($assetQuery->getSearch()); $result = []; diff --git a/src/Service/GenericData/V1/DataObjectSearchAdapter.php b/src/Service/GenericData/V1/DataObjectSearchAdapter.php index 874d6391e..42b28d86c 100644 --- a/src/Service/GenericData/V1/DataObjectSearchAdapter.php +++ b/src/Service/GenericData/V1/DataObjectSearchAdapter.php @@ -32,7 +32,7 @@ public function __construct( ) { } - public function searchDataObjects(DataObjectQuery $dataObjectQuery): DataObjectSearchResult + public function searchDataObjects(QueryInterface $dataObjectQuery): DataObjectSearchResult { $searchResult = $this->searchService->search($dataObjectQuery->getSearch()); $result = []; diff --git a/src/Service/GenericData/V1/QueryInterface.php b/src/Service/GenericData/V1/QueryInterface.php index 45a8648fd..712013c51 100644 --- a/src/Service/GenericData/V1/QueryInterface.php +++ b/src/Service/GenericData/V1/QueryInterface.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1; +use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\DataObjectSearchInterface; use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Interfaces\SearchInterface; interface QueryInterface @@ -32,5 +33,5 @@ public function setSearchTerm(?string $term): self; public function excludeFolders(): self; - public function getSearch(): SearchInterface; + public function getSearch(): SearchInterface|DataObjectSearchInterface; } From 3c601209647887a1da7f4c5de83f32add82465f8 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 05:54:31 +0000 Subject: [PATCH 4/9] Apply php-cs-fixer changes --- src/Controller/Api/DataObjects/CollectionController.php | 1 - src/Service/AssetSearchService.php | 1 - src/Service/DataObjectSearchService.php | 1 - src/Service/DataObjectSearchServiceInterface.php | 1 - src/Service/GenericData/AssetSearchAdapterInterface.php | 1 - src/Service/GenericData/DataObjectSearchAdapterInterface.php | 1 - 6 files changed, 6 deletions(-) diff --git a/src/Controller/Api/DataObjects/CollectionController.php b/src/Controller/Api/DataObjects/CollectionController.php index 4d1f2a786..0d8ca614b 100644 --- a/src/Controller/Api/DataObjects/CollectionController.php +++ b/src/Controller/Api/DataObjects/CollectionController.php @@ -37,7 +37,6 @@ use Pimcore\Bundle\StudioApiBundle\Request\Query\Filter\DataObjectParameters; use Pimcore\Bundle\StudioApiBundle\Service\DataObjectSearchServiceInterface; use Pimcore\Bundle\StudioApiBundle\Service\Filter\FilterServiceInterface; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Attribute\MapQueryString; use Symfony\Component\Routing\Attribute\Route; diff --git a/src/Service/AssetSearchService.php b/src/Service/AssetSearchService.php index 680a64f7c..a7e373c3c 100644 --- a/src/Service/AssetSearchService.php +++ b/src/Service/AssetSearchService.php @@ -26,7 +26,6 @@ use Pimcore\Bundle\StudioApiBundle\Response\Asset\Unknown; use Pimcore\Bundle\StudioApiBundle\Response\Asset\Video; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\AssetSearchAdapterInterface; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; final readonly class AssetSearchService implements AssetSearchServiceInterface diff --git a/src/Service/DataObjectSearchService.php b/src/Service/DataObjectSearchService.php index 7d55a17af..c09c8ee2a 100644 --- a/src/Service/DataObjectSearchService.php +++ b/src/Service/DataObjectSearchService.php @@ -17,7 +17,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Service; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\DataObjectSearchAdapterInterface; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; use Pimcore\Model\DataObject\Concrete; diff --git a/src/Service/DataObjectSearchServiceInterface.php b/src/Service/DataObjectSearchServiceInterface.php index 86bc8f174..a485dabda 100644 --- a/src/Service/DataObjectSearchServiceInterface.php +++ b/src/Service/DataObjectSearchServiceInterface.php @@ -16,7 +16,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Service; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; use Pimcore\Model\DataObject\Concrete; diff --git a/src/Service/GenericData/AssetSearchAdapterInterface.php b/src/Service/GenericData/AssetSearchAdapterInterface.php index 5770edd90..69c14cbdc 100644 --- a/src/Service/GenericData/AssetSearchAdapterInterface.php +++ b/src/Service/GenericData/AssetSearchAdapterInterface.php @@ -18,7 +18,6 @@ use Pimcore\Bundle\StudioApiBundle\Response\Asset; use Pimcore\Bundle\StudioApiBundle\Service\AssetSearchResult; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\AssetQuery; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; interface AssetSearchAdapterInterface diff --git a/src/Service/GenericData/DataObjectSearchAdapterInterface.php b/src/Service/GenericData/DataObjectSearchAdapterInterface.php index 072626708..47f63779a 100644 --- a/src/Service/GenericData/DataObjectSearchAdapterInterface.php +++ b/src/Service/GenericData/DataObjectSearchAdapterInterface.php @@ -17,7 +17,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Service\GenericData; use Pimcore\Bundle\StudioApiBundle\Service\DataObjectSearchResult; -use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\DataObjectQuery; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1\QueryInterface; use Pimcore\Model\Element\ElementInterface; From 86ea3cbf6ce8c90679ea11db24f7841d6205ec96 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 07:58:47 +0200 Subject: [PATCH 5/9] Add type doc typ hint --- src/Service/GenericData/V1/DataObjectSearchAdapter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Service/GenericData/V1/DataObjectSearchAdapter.php b/src/Service/GenericData/V1/DataObjectSearchAdapter.php index 42b28d86c..1bb25436a 100644 --- a/src/Service/GenericData/V1/DataObjectSearchAdapter.php +++ b/src/Service/GenericData/V1/DataObjectSearchAdapter.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1; +use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\DataObjectSearchInterface; use Pimcore\Bundle\GenericDataIndexBundle\Service\Search\SearchService\DataObject\DataObjectSearchServiceInterface; use Pimcore\Bundle\StaticResolverBundle\Models\Element\ServiceResolver; use Pimcore\Bundle\StudioApiBundle\Response\DataObject; @@ -34,7 +35,10 @@ public function __construct( public function searchDataObjects(QueryInterface $dataObjectQuery): DataObjectSearchResult { - $searchResult = $this->searchService->search($dataObjectQuery->getSearch()); + /** @var DataObjectSearchInterface $search */ + $search = $dataObjectQuery->getSearch(); + + $searchResult = $this->searchService->search($search); $result = []; foreach($searchResult->getIds() as $id) { /** @var Concrete $dataObject */ From 8300f74df141f537ad1a75b34df6dc741c42d65f Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 08:02:43 +0200 Subject: [PATCH 6/9] Try to remove interface from getSearch --- src/Service/GenericData/V1/QueryInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/GenericData/V1/QueryInterface.php b/src/Service/GenericData/V1/QueryInterface.php index 712013c51..5de0997fc 100644 --- a/src/Service/GenericData/V1/QueryInterface.php +++ b/src/Service/GenericData/V1/QueryInterface.php @@ -33,5 +33,5 @@ public function setSearchTerm(?string $term): self; public function excludeFolders(): self; - public function getSearch(): SearchInterface|DataObjectSearchInterface; + public function getSearch(): SearchInterface; } From 09ede2b236e0c54c9b84f09496d9b3556e29ceab Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 06:03:12 +0000 Subject: [PATCH 7/9] Apply php-cs-fixer changes --- src/Service/GenericData/V1/QueryInterface.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Service/GenericData/V1/QueryInterface.php b/src/Service/GenericData/V1/QueryInterface.php index 5de0997fc..45a8648fd 100644 --- a/src/Service/GenericData/V1/QueryInterface.php +++ b/src/Service/GenericData/V1/QueryInterface.php @@ -16,7 +16,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Service\GenericData\V1; -use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\DataObjectSearchInterface; use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Interfaces\SearchInterface; interface QueryInterface From a7cf6ee3beb9c7f2fb38c07492a9f7c755be1233 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 09:40:25 +0200 Subject: [PATCH 8/9] Change providers to interface too --- src/Exception/InvalidSearchException.php | 24 +++++++++++++++++++ .../GenericData/V1/AssetQueryProvider.php | 2 +- .../V1/AssetQueryProviderInterface.php | 2 +- .../V1/DataObjectQueryProvider.php | 2 +- .../V1/DataObjectQueryProviderInterface.php | 2 +- .../V1/DataObjectSearchAdapter.php | 16 +++++++++++-- 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 src/Exception/InvalidSearchException.php diff --git a/src/Exception/InvalidSearchException.php b/src/Exception/InvalidSearchException.php new file mode 100644 index 000000000..19f7716bc --- /dev/null +++ b/src/Exception/InvalidSearchException.php @@ -0,0 +1,24 @@ +searchProvider->createAssetSearch()); } diff --git a/src/Service/GenericData/V1/AssetQueryProviderInterface.php b/src/Service/GenericData/V1/AssetQueryProviderInterface.php index b0428781a..c8a0addaa 100644 --- a/src/Service/GenericData/V1/AssetQueryProviderInterface.php +++ b/src/Service/GenericData/V1/AssetQueryProviderInterface.php @@ -18,5 +18,5 @@ interface AssetQueryProviderInterface { - public function createAssetQuery(): AssetQuery; + public function createAssetQuery(): QueryInterface; } diff --git a/src/Service/GenericData/V1/DataObjectQueryProvider.php b/src/Service/GenericData/V1/DataObjectQueryProvider.php index a1bcd9233..be8265ae6 100644 --- a/src/Service/GenericData/V1/DataObjectQueryProvider.php +++ b/src/Service/GenericData/V1/DataObjectQueryProvider.php @@ -28,7 +28,7 @@ public function __construct( ) { } - public function createDataObjectQuery(): DataObjectQuery + public function createDataObjectQuery(): QueryInterface { /** @var DataObjectSearch $dataObjectSearch */ $dataObjectSearch = $this->searchProvider->createDataObjectSearch(); diff --git a/src/Service/GenericData/V1/DataObjectQueryProviderInterface.php b/src/Service/GenericData/V1/DataObjectQueryProviderInterface.php index efc50209c..a602b8ab1 100644 --- a/src/Service/GenericData/V1/DataObjectQueryProviderInterface.php +++ b/src/Service/GenericData/V1/DataObjectQueryProviderInterface.php @@ -18,5 +18,5 @@ interface DataObjectQueryProviderInterface { - public function createDataObjectQuery(): DataObjectQuery; + public function createDataObjectQuery(): QueryInterface; } diff --git a/src/Service/GenericData/V1/DataObjectSearchAdapter.php b/src/Service/GenericData/V1/DataObjectSearchAdapter.php index 1bb25436a..d1c1bce4e 100644 --- a/src/Service/GenericData/V1/DataObjectSearchAdapter.php +++ b/src/Service/GenericData/V1/DataObjectSearchAdapter.php @@ -19,6 +19,7 @@ use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\DataObject\DataObjectSearchInterface; use Pimcore\Bundle\GenericDataIndexBundle\Service\Search\SearchService\DataObject\DataObjectSearchServiceInterface; use Pimcore\Bundle\StaticResolverBundle\Models\Element\ServiceResolver; +use Pimcore\Bundle\StudioApiBundle\Exception\InvalidSearchException; use Pimcore\Bundle\StudioApiBundle\Response\DataObject; use Pimcore\Bundle\StudioApiBundle\Service\DataObjectSearchResult; use Pimcore\Bundle\StudioApiBundle\Service\GenericData\DataObjectSearchAdapterInterface; @@ -33,11 +34,22 @@ public function __construct( ) { } + /** + * @throws InvalidSearchException + */ public function searchDataObjects(QueryInterface $dataObjectQuery): DataObjectSearchResult { - /** @var DataObjectSearchInterface $search */ - $search = $dataObjectQuery->getSearch(); + $search = $dataObjectQuery->getSearch(); + if (!$search instanceof DataObjectSearchInterface) { + throw new InvalidSearchException( + sprintf( + 'Expected search to be an instance of %s, got %s', + DataObjectSearchInterface::class, + get_class($search) + ) + ); + } $searchResult = $this->searchService->search($search); $result = []; foreach($searchResult->getIds() as $id) { From 31b39a683da1221bf82a981fa5ee0d2cf353aa27 Mon Sep 17 00:00:00 2001 From: mattamon Date: Fri, 19 Apr 2024 07:40:58 +0000 Subject: [PATCH 9/9] Apply php-cs-fixer changes --- src/Exception/InvalidSearchException.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Exception/InvalidSearchException.php b/src/Exception/InvalidSearchException.php index 19f7716bc..17ab96cbd 100644 --- a/src/Exception/InvalidSearchException.php +++ b/src/Exception/InvalidSearchException.php @@ -20,5 +20,4 @@ final class InvalidSearchException extends Exception { - -} \ No newline at end of file +}