diff --git a/src/ClassificationStore/Controller/GetLayoutByKeyController.php b/src/ClassificationStore/Controller/GetLayoutByKeyController.php index ca184acf0..2cee876bf 100644 --- a/src/ClassificationStore/Controller/GetLayoutByKeyController.php +++ b/src/ClassificationStore/Controller/GetLayoutByKeyController.php @@ -55,13 +55,13 @@ public function __construct( * @throws NotFoundException */ #[Route( - path: '/classification-store/layout-by-key/{keyId}', + path: '/classification-store/layout-by-key/{keyId}/{groupId}', name: 'pimcore_studio_api_classification_store_get_layout_by_key', methods: ['GET'] )] #[IsGranted(UserPermissions::DATA_OBJECTS->value)] #[Get( - path: self::PREFIX . '/classification-store/layout-by-key/{keyId}', + path: self::PREFIX . '/classification-store/layout-by-key/{keyId}/{groupId}', operationId: 'classification_store_get_layout_by_key', description: 'classification_store_get_layout_by_key_description', summary: 'classification_store_get_layout_by_key_summary', @@ -80,6 +80,10 @@ public function __construct( type: 'Key ID', name: 'keyId', )] + #[PathIdParameter( + type: 'Group ID', + name: 'groupId', + )] #[TextFieldParameter( name: 'fieldName', description: 'Field Name', @@ -94,9 +98,10 @@ public function __construct( public function getLayoutByKey( #[MapQueryString] LayoutParameter $layoutParameter, int $keyId, + int $groupId ): JsonResponse { return $this->jsonResponse( - $this->keyGroupLayoutService->getKeyLayout($layoutParameter, $keyId) + $this->keyGroupLayoutService->getKeyLayout($layoutParameter, $keyId, $groupId) ); } } diff --git a/src/ClassificationStore/Repository/KeyGroupRelationRepository.php b/src/ClassificationStore/Repository/KeyGroupRelationRepository.php index ded8ddd5f..e00267d91 100644 --- a/src/ClassificationStore/Repository/KeyGroupRelationRepository.php +++ b/src/ClassificationStore/Repository/KeyGroupRelationRepository.php @@ -68,11 +68,12 @@ public function getByGroupId(int $groupId): array /** * @inheritDoc */ - public function getByKeyId(int $keyId): KeyGroupRelation + public function getByKeyGroupId(int $keyId, int $groupId): KeyGroupRelation { $listing = new Listing(); $listing->setOrder('ASC'); - $listing->setCondition('id = ?', $keyId); + $listing->addConditionParam('keyId = ?', $keyId); + $listing->addConditionParam('groupId = ?', $groupId); $list = $listing->load(); diff --git a/src/ClassificationStore/Repository/KeyGroupRelationRepositoryInterface.php b/src/ClassificationStore/Repository/KeyGroupRelationRepositoryInterface.php index 5bb798bd5..e614b9aeb 100644 --- a/src/ClassificationStore/Repository/KeyGroupRelationRepositoryInterface.php +++ b/src/ClassificationStore/Repository/KeyGroupRelationRepositoryInterface.php @@ -42,5 +42,5 @@ public function getByGroupId(int $groupId): array; /** * @throws NotFoundException */ - public function getByKeyId(int $keyId): KeyGroupRelation; + public function getByKeyGroupId(int $keyId, int $groupId): KeyGroupRelation; } diff --git a/src/ClassificationStore/Service/KeyGroupLayoutService.php b/src/ClassificationStore/Service/KeyGroupLayoutService.php index 7b2d6e108..bafe59bc8 100644 --- a/src/ClassificationStore/Service/KeyGroupLayoutService.php +++ b/src/ClassificationStore/Service/KeyGroupLayoutService.php @@ -76,7 +76,8 @@ public function getLayoutDefinition( */ public function getKeyLayout( LayoutParameter $layoutParameter, - int $keyId + int $keyId, + int $groupId ): KeyLayout { $object = null; @@ -88,7 +89,7 @@ public function getKeyLayout( } } - $key = $this->keyGroupRelationRepository->getByKeyId($keyId); + $key = $this->keyGroupRelationRepository->getByKeyGroupId($keyId, $groupId); $definition = $this->getLayoutDefinition($key, $layoutParameter->getFieldName(), $object); return new KeyLayout( diff --git a/src/ClassificationStore/Service/KeyGroupLayoutServiceInterface.php b/src/ClassificationStore/Service/KeyGroupLayoutServiceInterface.php index da1d41128..7104d2427 100644 --- a/src/ClassificationStore/Service/KeyGroupLayoutServiceInterface.php +++ b/src/ClassificationStore/Service/KeyGroupLayoutServiceInterface.php @@ -38,5 +38,6 @@ public function getLayoutDefinition( public function getKeyLayout( LayoutParameter $layoutParameter, int $keyId, + int $groupId ): KeyLayout; } diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/BooleanFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/BooleanFilter.php index 168665121..c6b1ba7dd 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/BooleanFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/BooleanFilter.php @@ -53,7 +53,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); if (!is_array($filterValue->getValue())) { diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/DateFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/DateFilter.php index 97bd4e82c..7507d1cb7 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/DateFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/DateFilter.php @@ -50,7 +50,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface foreach ($parameters->getColumnFilterByType(ColumnType::CLASSIFICATION_STORE_DATE->value) as $column) { $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); /** @var DataObjectQueryInterface $query */ $query = $this->applyClassificationStoreDateFilter($column, $query, $key, $group, $filterValue, true); diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/DateTimeFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/DateTimeFilter.php index 5faa9dbc8..d7bd82be4 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/DateTimeFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/DateTimeFilter.php @@ -50,7 +50,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface foreach ($parameters->getColumnFilterByType(ColumnType::CLASSIFICATION_STORE_DATETIME->value) as $column) { $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); /** @var DataObjectQueryInterface $query */ $query = $this->applyClassificationStoreDateFilter($column, $query, $key, $group, $filterValue, false); diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/InputQuantityValueFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/InputQuantityValueFilter.php index 556254b00..de40fc9dd 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/InputQuantityValueFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/InputQuantityValueFilter.php @@ -54,7 +54,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); $value = $filterValue->getValue(); diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/NumberFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/NumberFilter.php index 5160134a2..a42d57c24 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/NumberFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/NumberFilter.php @@ -66,7 +66,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $this->addFilterToQuery( $query, $column, - $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()), + $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ), $this->groupConfigRepository->getById($filterValue->getGroupId()), $mode, $isValue, diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/QuantityValueFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/QuantityValueFilter.php index b7c7a1642..6179fb8fc 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/QuantityValueFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/QuantityValueFilter.php @@ -56,7 +56,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); $value = $filterValue->getValue(); diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/RGBAFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/RGBAFilter.php index d7f53ef42..c001302b0 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/RGBAFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/RGBAFilter.php @@ -53,7 +53,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); $value = $filterValue->getValue(); diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/SelectFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/SelectFilter.php index 023309d8c..d54847746 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/SelectFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/SelectFilter.php @@ -53,7 +53,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); if (!is_array($filterValue->getValue())) { diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/StringFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/StringFilter.php index b372a4f80..7b3ba51ec 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/StringFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/StringFilter.php @@ -53,7 +53,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); if (!is_string($filterValue->getValue())) { diff --git a/src/DataIndex/Filter/DataObject/Classificationstore/TimeFilter.php b/src/DataIndex/Filter/DataObject/Classificationstore/TimeFilter.php index 98c7becdb..1ad6ff3e2 100644 --- a/src/DataIndex/Filter/DataObject/Classificationstore/TimeFilter.php +++ b/src/DataIndex/Filter/DataObject/Classificationstore/TimeFilter.php @@ -53,7 +53,10 @@ public function apply(mixed $parameters, QueryInterface $query): QueryInterface foreach ($parameters->getColumnFilterByType(ColumnType::CLASSIFICATION_STORE_TIME->value) as $column) { $filterValue = $this->getClassificationStoreFilterValue($column->getFilterValue()); - $key = $this->keyGroupRelationRepository->getByKeyId($filterValue->getKeyId()); + $key = $this->keyGroupRelationRepository->getByKeyGroupId( + $filterValue->getKeyId(), + $filterValue->getGroupId() + ); $group = $this->groupConfigRepository->getById($filterValue->getGroupId()); /** @var DataObjectQueryInterface $query */ $query = $this->applyTimeFilter($column, $query, $key, $group, $filterValue);