Skip to content

Commit

Permalink
feat: relly assets on storage cache (asset local cache are deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 committed Jul 1, 2024
1 parent 3cff697 commit 2f24583
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions EMS/client-helper-bundle/src/Helper/Asset/AssetHelperRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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');
Expand Down

0 comments on commit 2f24583

Please sign in to comment.