From 1298a8382d8d6483263a0d9119f5a960e995800a Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 19 Oct 2023 11:17:35 +0300 Subject: [PATCH] export: use additional applier --- application/Espo/Tools/Export/Export.php | 9 +++++++-- application/Espo/Tools/Export/Params.php | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/application/Espo/Tools/Export/Export.php b/application/Espo/Tools/Export/Export.php index 05f852f7ad..19de215902 100644 --- a/application/Espo/Tools/Export/Export.php +++ b/application/Espo/Tools/Export/Export.php @@ -30,6 +30,7 @@ namespace Espo\Tools\Export; use Espo\Core\ORM\Repository\Option\SaveOption; +use Espo\Core\Record\Select\ApplierClassNameListProvider; use Espo\Tools\Export\Collection as ExportCollection; use Espo\Tools\Export\Processor\Params as ProcessorParams; use Espo\ORM\Entity; @@ -72,7 +73,8 @@ class Export private FileStorageManager $fileStorageManager, private ListLoadProcessor $listLoadProcessor, private FieldUtil $fieldUtil, - private User $user + private User $user, + private ApplierClassNameListProvider $applierClassNameListProvider ) {} public function setParams(Params $params): self @@ -174,7 +176,7 @@ class Export $fileName = $fileName ? $fileName . '.' . $fileExtension : - "Export_{$entityType}.{$fileExtension}"; + "Export_$entityType.$fileExtension"; $processorParams = (new ProcessorParams($fileName, $attributeList, $fieldList)) ->withName($params->getName()) @@ -291,6 +293,9 @@ class Export ->create() ->forUser($this->user) ->from($entityType) + ->withAdditionalApplierClassNameList( + $this->applierClassNameListProvider->get($entityType) + ) ->withSearchParams($searchParams); if ($params->applyAccessControl()) { diff --git a/application/Espo/Tools/Export/Params.php b/application/Espo/Tools/Export/Params.php index 08a6440106..47d04eb83c 100644 --- a/application/Espo/Tools/Export/Params.php +++ b/application/Espo/Tools/Export/Params.php @@ -146,6 +146,7 @@ class Params return $obj; } + /** @noinspection PhpUnused */ public function withFileName(?string $fileName): self { $obj = clone $this; @@ -213,11 +214,17 @@ class Params */ public function getSearchParams(): SearchParams { - if (!$this->searchParams) { - return SearchParams::create(); + $searchParams = $this->searchParams ?? SearchParams::create(); + + if ($searchParams->getSelect() !== null) { + return $searchParams; } - return $this->searchParams; + if ($this->getAttributeList()) { + $searchParams = $searchParams->withSelect($this->getAttributeList()); + } + + return $searchParams; } /**