Skip to content

Commit

Permalink
ref: updateStyleSets function
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Oct 11, 2024
1 parent 5197cbc commit 9169ee7
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions EMS/client-helper-bundle/src/Command/Local/UploadAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)));
}
}

0 comments on commit 9169ee7

Please sign in to comment.