diff --git a/EMS/client-helper-bundle/src/Helper/Asset/AssetHelperRuntime.php b/EMS/client-helper-bundle/src/Helper/Asset/AssetHelperRuntime.php index d8a278032..3cc2069ac 100644 --- a/EMS/client-helper-bundle/src/Helper/Asset/AssetHelperRuntime.php +++ b/EMS/client-helper-bundle/src/Helper/Asset/AssetHelperRuntime.php @@ -25,12 +25,16 @@ public function __construct(private readonly StorageManager $storageManager, pri $this->filesystem = new Filesystem(); } - public function setVersion(string $hash, string $saveDir = 'bundles'): string + public function setVersion(string $hash, ?string $saveDir = 'bundles'): ?string { if (null !== $this->versionHash && $this->versionHash !== $hash) { throw new \RuntimeException('Another hash version has been already defined'); } $this->versionHash = $hash; + if (null === $saveDir) { + return null; + } + \trigger_error('Specify a save directory and retrieving a path to the assets are deprecated, use emsch_assets_versionwith a null saveDir parameter', E_USER_DEPRECATED); $this->versionSaveDir = $saveDir; if (!empty($this->localFolder)) { return $this->publicDir.DIRECTORY_SEPARATOR.$this->localFolder; @@ -86,6 +90,10 @@ public function asset(string $path, array $assetConfig = []): string public function applyVersion(string $path): string { + if (null === $this->versionSaveDir) { + return \sprintf('bundle/%s/%s', $this->getVersionHash(), $path); + } + if (!empty($this->localFolder)) { return \sprintf('%s/%s', $this->localFolder, $path); } @@ -102,7 +110,7 @@ public function getVersionHash(): string return $this->versionHash; } - public function getVersionSaveDir(): string + public function getVersionSaveDir(): ?string { if (null === $this->versionSaveDir) { throw new \RuntimeException('Asset version has not been set');