Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ services:
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Handler\AssetCloneHandler: ~
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Handler\AssetUploadHandler: ~
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Handler\ExportDataCollectionHandler: ~
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Handler\ExportFolderDataCollectionHandler: ~
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Handler\ZipDownloadHandler: ~
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Handler\ZipUploadHandler: ~

Expand Down
1 change: 0 additions & 1 deletion config/data_objects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ services:

Pimcore\Bundle\StudioBackendBundle\DataObject\ExecutionEngine\AutomationAction\Messenger\Handler\CloneHandler: ~
Pimcore\Bundle\StudioBackendBundle\DataObject\ExecutionEngine\AutomationAction\Messenger\Handler\ExportDataCollectionHandler: ~
Pimcore\Bundle\StudioBackendBundle\DataObject\ExecutionEngine\AutomationAction\Messenger\Handler\ExportFolderDataCollectionHandler: ~

#
# Event Subscriber
Expand Down
1 change: 1 addition & 0 deletions config/elements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ services:
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Handler\PatchHandler: ~
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Handler\PatchFolderHandler: ~
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Handler\ElementUsageReplaceHandler: ~
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Handler\RefreshJobHandler: ~

#
# Event Subscriber
Expand Down
2 changes: 2 additions & 0 deletions config/export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ services:
arguments:
$xlsxExportService: '@Pimcore\Bundle\StudioBackendBundle\Export\Service\XlsxExportService'

Pimcore\Bundle\StudioBackendBundle\Export\ExecutionEngine\AutomationAction\Messenger\Handler\FolderCollectionHandler: ~

#
# Services
#
Expand Down
4 changes: 2 additions & 2 deletions config/pimcore/execution_engine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ framework:
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\AssetCloneMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\AssetUploadMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\ExportDataCollectionMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\ExportFolderDataCollectionMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\ZipDownloadMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\ZipUploadMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\DataObject\ExecutionEngine\AutomationAction\Messenger\Messages\CloneMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\DataObject\ExecutionEngine\AutomationAction\Messenger\Messages\ExportDataCollectionMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\DataObject\ExecutionEngine\AutomationAction\Messenger\Messages\ExportFolderDataCollectionMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Document\ExecutionEngine\AutomationAction\Messenger\Messages\CloneMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\BatchDeleteMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\ElementDeleteMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\PatchFolderMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\PatchMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\RefreshJobMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\RecycleBinMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Element\ExecutionEngine\AutomationAction\Messenger\Messages\RewriteRefMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Export\ExecutionEngine\AutomationAction\Messenger\Messages\CsvCreationMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Export\ExecutionEngine\AutomationAction\Messenger\Messages\XlsxCreationMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Export\ExecutionEngine\AutomationAction\Messenger\Messages\FolderCollectionMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\Tag\ExecutionEngine\AutomationAction\Messenger\Messages\BatchTagOperationMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\RecycleBin\ExecutionEngine\Messages\DeleteItemsMessage: pimcore_generic_execution_engine
Pimcore\Bundle\StudioBackendBundle\RecycleBin\ExecutionEngine\Messages\RestoreItemsMessage: pimcore_generic_execution_engine
Expand Down
25 changes: 7 additions & 18 deletions src/Asset/Attribute/Request/PatchAssetFolderRequestBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Pimcore\Bundle\StudioBackendBundle\Asset\Attribute\Request;

use Attribute;
use OpenApi\Attributes\Items;
use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Property;
use OpenApi\Attributes\RequestBody;
Expand All @@ -39,23 +38,13 @@ public function __construct()
properties: [
new Property(
property: 'data',
type: 'array',
items: new Items(
required: ['folderId'],
properties: [
new Property(
property: 'folderId',
description: 'Folder ID',
type: 'integer',
example: 83
),
new UpdateIntegerProperty('parentId'),
new UpdateStringProperty('key'),
new UpdateStringProperty('locked'),
new CustomMetadata(PatchCustomMetadata::class),
],
type: 'object',
),
properties: [
new UpdateIntegerProperty('parentId'),
new UpdateStringProperty('key'),
new UpdateStringProperty('locked'),
new CustomMetadata(PatchCustomMetadata::class),
],
type: 'object',
),
new Property(
property: 'filters',
Expand Down
16 changes: 11 additions & 5 deletions src/Asset/Controller/PatchFolderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\UserNotFoundException;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\PatchFolderParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\IdJson;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\CreatedResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
Expand All @@ -38,6 +39,8 @@
*/
final class PatchFolderController extends AbstractApiController
{
private const string ROUTE = '/assets/folder/{id}';

public function __construct(
SerializerInterface $serializer,
private readonly PatchServiceInterface $patchService,
Expand All @@ -49,15 +52,16 @@ public function __construct(
/**
* @throws UserNotFoundException
*/
#[Route('/assets/folder', name: 'pimcore_studio_api_patch_asset_folder', methods: ['PATCH'])]
#[Route(self::ROUTE, name: 'pimcore_studio_api_patch_asset_folder', methods: ['PATCH'])]
#[IsGranted(UserPermissions::ASSETS->value)]
#[Patch(
path: self::PREFIX . '/assets/folder',
path: self::PREFIX . self::ROUTE,
operationId: 'asset_patch_folder_by_id',
description: 'asset_patch_folder_by_id_description',
summary: 'asset_patch_folder_by_id_summary',
tags: [Tags::Assets->name]
)]
#[IdParameter(type: ElementTypes::TYPE_FOLDER, name: 'id')]
#[PatchAssetFolderRequestBody]
#[CreatedResponse(
description: 'asset_patch_by_id_created_response',
Expand All @@ -67,10 +71,12 @@ public function __construct(
HttpResponseCodes::NOT_FOUND,
HttpResponseCodes::UNAUTHORIZED,
])]
public function assetPatchFolderById(#[MapRequestPayload] PatchFolderParameter $patchFolderParameter): Response
{

public function assetPatchFolderById(
int $id,
#[MapRequestPayload] PatchFolderParameter $patchFolderParameter
): Response {
$jobRunId = $this->patchService->patchFolder(
$id,
ElementTypes::TYPE_ASSET,
$patchFolderParameter,
$this->securityService->getCurrentUser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Exception;
use Pimcore\Bundle\StaticResolverBundle\Models\User\UserResolverInterface;
use Pimcore\Bundle\StudioBackendBundle\Asset\ExecutionEngine\AutomationAction\Messenger\Messages\ExportDataCollectionMessage;
use Pimcore\Bundle\StudioBackendBundle\Asset\Service\AssetServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\ExecutionEngine\AutomationAction\AbstractHandler;
use Pimcore\Bundle\StudioBackendBundle\ExecutionEngine\Util\Config;
use Pimcore\Bundle\StudioBackendBundle\ExecutionEngine\Util\StepConfig;
Expand All @@ -27,6 +26,7 @@
use Pimcore\Bundle\StudioBackendBundle\Mercure\Service\PublishServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementTypes;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use function count;

/**
* @internal
Expand All @@ -41,8 +41,7 @@ public function __construct(
private readonly ColumnConfigurationServiceInterface $columnConfigurationService,
private readonly PublishServiceInterface $publishService,
private readonly UserResolverInterface $userResolver,
private readonly GridServiceInterface $gridService,
private readonly AssetServiceInterface $assetService
private readonly GridServiceInterface $gridService
) {
parent::__construct();
}
Expand All @@ -68,65 +67,55 @@ public function __invoke(ExportDataCollectionMessage $message): void
));
}

$jobAsset = $this->extractConfigFieldFromJobStepConfig($message, StepConfig::ELEMENT_TO_EXPORT->value);

$asset = $this->assetService->getAssetForUser($jobAsset['id'], $user);

if ($asset->getType() === ElementTypes::TYPE_FOLDER) {
$this->abort($this->getAbortData(
Config::ELEMENT_FOLDER_COLLECTION_NOT_SUPPORTED->value,
[
'folderId' => $asset->getId(),
]
));

return;
}

$assets = $this->extractConfigFieldFromJobStepConfig($message, StepConfig::ELEMENTS_TO_EXPORT->value);
$totalAssets = count($assets);
$columns = $this->extractConfigFieldFromJobStepConfig($message, StepConfig::CONFIG_COLUMNS->value);

$columnsDefinitions = $this->columnConfigurationService->getAvailableAssetColumnConfiguration();

$columnCollection = $this->gridService->getConfigurationForExport(
$columns,
$columnsDefinitions
);
$columnCollection = $this->gridService->getConfigurationForExport($columns, $columnsDefinitions);

try {
$assetData = [
$asset->getId() => $this->gridService->getGridValuesForElement(
$assetsData = [];
foreach ($assets as $asset) {
try {
$assetsData[$asset['id']] = $this->gridService->getGridValuesForElement(
$columnCollection,
ElementTypes::TYPE_ASSET,
$asset->getId(),
true,
$asset['id'],
$user
),
];

$this->updateContextArrayValues($jobRun, StepConfig::GRID_EXPORT_DATA->value, $assetData);

$csvExportDataInfo = $jobRun->getContext()[StepConfig::GRID_EXPORT_DATA_INFO->value] ?? null;
);

if ($csvExportDataInfo === null) {
$this->updateContextArrayValues(
$jobRun,
StepConfig::GRID_EXPORT_DATA_INFO->value,
} catch (Exception $e) {
$this->abort($this->getAbortData(
Config::CSV_DATA_COLLECTION_FAILED_MESSAGE->value,
[
'type' => ElementTypes::TYPE_ASSET,
'id' => $asset['id'],
'message' => $e->getMessage(),
]
);
));
}

$this->updateProgress($this->publishService, $jobRun, $this->getJobStep($message)->getName(), $totalAssets);
}

try {
if (!empty($assetsData)) {
$context = $jobRun->getContext();
if (isset($context[StepConfig::GRID_EXPORT_DATA->value])) {
$assetsData = array_merge(
$context[StepConfig::GRID_EXPORT_DATA->value],
$assetsData
);
}
$this->updateJobRunContext($jobRun, StepConfig::GRID_EXPORT_DATA->value, $assetsData);
}
} catch (Exception $e) {
$this->abort($this->getAbortData(
Config::CSV_DATA_COLLECTION_FAILED_MESSAGE->value,
[
'id' => $asset->getId(),
'message' => $e->getMessage(),
]
));
}

$this->updateProgress($this->publishService, $jobRun, $this->getJobStep($message)->getName());
}
}
Loading
Loading