From 9169ee75a15dd86ea31fd3ccc4f7425e33d74be9 Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Fri, 11 Oct 2024 18:33:37 +0200 Subject: [PATCH] ref: updateStyleSets function --- .../src/Command/Local/UploadAssetsCommand.php | 49 ++++++++++--------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/EMS/client-helper-bundle/src/Command/Local/UploadAssetsCommand.php b/EMS/client-helper-bundle/src/Command/Local/UploadAssetsCommand.php index 74b6c87cf..98b2c1b6e 100644 --- a/EMS/client-helper-bundle/src/Command/Local/UploadAssetsCommand.php +++ b/EMS/client-helper-bundle/src/Command/Local/UploadAssetsCommand.php @@ -56,6 +56,33 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::EXECUTE_ERROR; } + return $this->uploadZipArchive(); + } + + private function updateStyleSets(string $hash): void + { + if (!$this->updateStyleSets) { + return; + } + $styleSetClient = $this->coreApi->admin()->getConfig(ConfigTypes::WYSIWYG_STYLE_SET->value); + $styleSetNames = $styleSetClient->index(); + if (empty($styleSetNames)) { + return; + } + foreach ($styleSetNames as $name) { + $styleSet = $styleSetClient->get($name); + $styleSet['properties']['assets'] = [ + EmsFields::CONTENT_FILE_HASH_FIELD => $hash, + EmsFields::CONTENT_MIME_TYPE_FIELD => MimeTypes::APPLICATION_ZIP, + EmsFields::CONTENT_FILE_NAME_FIELD => 'bundle.zip', + ]; + $styleSetClient->update($name, $styleSet); + } + $this->io->success(\sprintf('%d style sets have been updated', \count($styleSetNames))); + } + + private function uploadZipArchive(): int + { try { $assetsArchive = $this->localHelper->makeAssetsArchives($this->baseUrl); } catch (\Throwable $e) { @@ -91,26 +118,4 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::EXECUTE_ERROR; } } - - private function updateStyleSets(string $hash): void - { - if (!$this->updateStyleSets) { - return; - } - $styleSetClient = $this->coreApi->admin()->getConfig(ConfigTypes::WYSIWYG_STYLE_SET->value); - $styleSetNames = $styleSetClient->index(); - if (empty($styleSetNames)) { - return; - } - foreach ($styleSetNames as $name) { - $styleSet = $styleSetClient->get($name); - $styleSet['properties']['assets'] = [ - EmsFields::CONTENT_FILE_HASH_FIELD => $hash, - EmsFields::CONTENT_MIME_TYPE_FIELD => MimeTypes::APPLICATION_ZIP, - EmsFields::CONTENT_FILE_NAME_FIELD => 'bundle.zip', - ]; - $styleSetClient->update($name, $styleSet); - } - $this->io->success(\sprintf('%d style sets have been updated', \count($styleSetNames))); - } }