Skip to content

Commit

Permalink
Merge branch '5.21' into 5.22
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei committed Oct 11, 2024
2 parents 6091702 + f7057ea commit e97dfed
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function applyVersion(string $path): string
return \sprintf('%s/%s', $this->localFolder, $path);
}
if (null === $this->versionSaveDir) {
return \sprintf('bundle/%s/%s', $this->getVersionHash(), $path);
return \sprintf('bundles/%s/%s', $this->getVersionHash(), $path);
}

return \sprintf('%s/%s/%s', $this->getVersionSaveDir(), $this->getVersionHash(), $path);
Expand Down
2 changes: 1 addition & 1 deletion EMS/common-bundle/src/Resources/config/routing/assets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing https://symfony.com/schema/routing/routing-1.0.xsd">
<route id="ems_asset_in_archive" path="/bundle/{hash}/{path}"
<route id="ems_asset_in_archive" path="/bundles/{hash}/{path}"
controller="EMS\CommonBundle\Controller\FileController::assetInArchive"
methods="GET">
<requirement key="path">.+</requirement>
Expand Down
15 changes: 9 additions & 6 deletions EMS/core-bundle/src/Form/DataField/WysiwygFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ public function buildView(FormView $view, FormInterface $form, array $options):
$contentCss ??= $styleSet->getContentCss();
$assets = $styleSet->getAssets();
$hash = $assets['sha1'] ?? null;
if (null !== $assets && \is_string($hash)) {
$saveDir = $styleSet->getSaveDir();
$this->assetRuntime->unzip($hash, $saveDir ?? \sprintf('bundles/%s', $hash));
if (null === $saveDir) {
$contentCss = \sprintf('/bundles/%s/%s', $hash, $styleSet->getContentCss());
}
$saveDir = $styleSet->getSaveDir();
if (null !== $assets && \is_string($hash) && null !== $saveDir) {
$this->assetRuntime->unzip($hash, $saveDir);
}
if (null === $saveDir && $contentCss) {
$contentCss = $this->router->generate('ems_asset_in_archive', [
'hash' => $hash,
'path' => $contentCss,
]);
}
$attr['data-table-default-css'] = $styleSet->getTableDefaultCss();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<style>body {overflow: hidden;}</style>
{% apply spaceless %}
{% if styleSet.assets.sha1|default %}
{% do emsch_assets_version(styleSet.assets.sha1) %}
{% do emsch_assets_version(styleSet.assets.sha1, styleSet.saveDir) %}
{% endif %}
{% if null != styleSet.contentCss %}
<link rel="stylesheet" href="{{ asset(styleSet.contentCss, styleSet.saveDir == null ? 'emsch' : null) }}">
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

Example ```emsco:xliff:update /tmp/pages-nl-to-de.xlf --base-url=https://my-admin.my-project.tld```
* You should not specify a folder where to expand website assets in the `emsch_assets_version` twig function, in this case the function returns `null`.
* By default, if you specify `null` (e.g. `{% do emsch_assets_version(include('@EMSCH/template/asset_hash.twig'), null) %}`) as second arguments, the `emsch` assets will have a an url like `/bundle/253b903b1fb3ac30975ae9844a0352a65cdcfa3d/site.css` which urls will be resolved by the route `EMS\CommonBundle\Controller\FileController::assetInArchive`
* By default, if you specify `null` (e.g. `{% do emsch_assets_version(include('@EMSCH/template/asset_hash.twig'), null) %}`) as second arguments, the `emsch` assets will have a an url like `/bundles/253b903b1fb3ac30975ae9844a0352a65cdcfa3d/site.css` which urls will be resolved by the route `EMS\CommonBundle\Controller\FileController::assetInArchive`
* It's also possible the defined you own route for assets in archive, if the route is not immutable (does not contain the archive hash) you must specify the `maxAge` argument (by default it's set to one week):
```yaml
emsch_demo_asset_in_archive:
Expand Down

0 comments on commit e97dfed

Please sign in to comment.