diff --git a/ListRepresentation/DoctrineListRepresentationFactory.php b/ListRepresentation/DoctrineListRepresentationFactory.php index 8b729b1..55dd3c7 100644 --- a/ListRepresentation/DoctrineListRepresentationFactory.php +++ b/ListRepresentation/DoctrineListRepresentationFactory.php @@ -48,11 +48,13 @@ public function __construct( /** * @param mixed[] $filters * @param mixed[] $parameters + * @param string[] $includedFields */ public function createDoctrineListRepresentation( string $resourceKey, array $filters = [], - array $parameters = [] + array $parameters = [], + array $includedFields = [] ): PaginatedRepresentation { /** @var DoctrineFieldDescriptor[] $fieldDescriptors */ $fieldDescriptors = $this->fieldDescriptorFactory->getFieldDescriptors($resourceKey); @@ -68,6 +70,10 @@ public function createDoctrineListRepresentation( $listBuilder->where($fieldDescriptors[$key], $value); } + foreach ($includedFields as $field) { + $listBuilder->addSelectField($fieldDescriptors[$field]); + } + $items = $listBuilder->execute(); // sort the items to reflect the order of the given ids if the list was requested to include specific ids diff --git a/ListRepresentation/DoctrineListRepresentationFactoryInterface.php b/ListRepresentation/DoctrineListRepresentationFactoryInterface.php index 9526a48..67f51d0 100644 --- a/ListRepresentation/DoctrineListRepresentationFactoryInterface.php +++ b/ListRepresentation/DoctrineListRepresentationFactoryInterface.php @@ -11,10 +11,12 @@ interface DoctrineListRepresentationFactoryInterface /** * @param mixed[] $filters * @param mixed[] $parameters + * @param string[] $includedFields */ public function createDoctrineListRepresentation( string $resourceKey, array $filters = [], - array $parameters = [] + array $parameters = [], + array $includedFields = [] ): PaginatedRepresentation; }