From 841392d026d159368e3faebbdd3e195e29e5d917 Mon Sep 17 00:00:00 2001 From: Luca Rath-Heel Date: Mon, 7 Nov 2022 14:42:36 +0100 Subject: [PATCH] Add listKey argument to DoctrineListRepresentationFactory and DoctrineNestedListRepresentationFactory (#10) --- ListRepresentation/DoctrineListRepresentationFactory.php | 7 +++++-- .../DoctrineListRepresentationFactoryInterface.php | 3 ++- .../DoctrineNestedListRepresentationFactory.php | 7 +++++-- .../DoctrineNestedListRepresentationFactoryInterface.php | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ListRepresentation/DoctrineListRepresentationFactory.php b/ListRepresentation/DoctrineListRepresentationFactory.php index b5c0451..e425afb 100644 --- a/ListRepresentation/DoctrineListRepresentationFactory.php +++ b/ListRepresentation/DoctrineListRepresentationFactory.php @@ -56,10 +56,13 @@ public function createDoctrineListRepresentation( array $filters = [], array $parameters = [], array $includedFields = [], - array $groupByFields = [] + array $groupByFields = [], + string $listKey = null ): PaginatedRepresentation { + $listKey = $listKey ?? $resourceKey; + /** @var DoctrineFieldDescriptor[] $fieldDescriptors */ - $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors($resourceKey); + $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors($listKey); $listBuilder = $this->listBuilderFactory->create($fieldDescriptors['id']->getEntityName()); $this->restHelper->initializeListBuilder($listBuilder, $fieldDescriptors); diff --git a/ListRepresentation/DoctrineListRepresentationFactoryInterface.php b/ListRepresentation/DoctrineListRepresentationFactoryInterface.php index 9f6bfc8..82ba0d4 100644 --- a/ListRepresentation/DoctrineListRepresentationFactoryInterface.php +++ b/ListRepresentation/DoctrineListRepresentationFactoryInterface.php @@ -19,6 +19,7 @@ public function createDoctrineListRepresentation( array $filters = [], array $parameters = [], array $includedFields = [], - array $groupByFields = [] + array $groupByFields = [], + string $listKey = null ): PaginatedRepresentation; } diff --git a/ListRepresentation/DoctrineNestedListRepresentationFactory.php b/ListRepresentation/DoctrineNestedListRepresentationFactory.php index 76d1176..393814a 100644 --- a/ListRepresentation/DoctrineNestedListRepresentationFactory.php +++ b/ListRepresentation/DoctrineNestedListRepresentationFactory.php @@ -61,10 +61,13 @@ public function createDoctrineListRepresentation( $parentId = null, array $expandedIds = [], array $includedFields = [], - array $groupByFields = [] + array $groupByFields = [], + string $listKey = null ): CollectionRepresentation { + $listKey = $listKey ?? $resourceKey; + /** @var DoctrineFieldDescriptor[] $fieldDescriptors */ - $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors($resourceKey); + $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors($listKey); $listBuilder = $this->listBuilderFactory->create($fieldDescriptors['id']->getEntityName()); $this->restHelper->initializeListBuilder($listBuilder, $fieldDescriptors); diff --git a/ListRepresentation/DoctrineNestedListRepresentationFactoryInterface.php b/ListRepresentation/DoctrineNestedListRepresentationFactoryInterface.php index 00e80e6..36aee44 100644 --- a/ListRepresentation/DoctrineNestedListRepresentationFactoryInterface.php +++ b/ListRepresentation/DoctrineNestedListRepresentationFactoryInterface.php @@ -23,6 +23,7 @@ public function createDoctrineListRepresentation( $parentId = null, array $expandedIds = [], array $includedFields = [], - array $groupByFields = [] + array $groupByFields = [], + string $listKey = null ): CollectionRepresentation; }