Skip to content

Instantly share code, notes, and snippets.

@alongosz
Created February 5, 2018 13:20
Show Gist options
  • Save alongosz/dc881b8be0fac613ac40720d6d8ebab2 to your computer and use it in GitHub Desktop.
Save alongosz/dc881b8be0fac613ac40720d6d8ebab2 to your computer and use it in GitHub Desktop.
eZ Design namespace for assets
<?php
/**
* Resolve Asset URL optionally prefixed with package name.
*
* @param string $path Asset URL
*
* @return string
*/
private function resolveAssetUrl($path): string
{
$packageName = null;
if (preg_match('#^@(.+?)/#', $path, $matches)) {
$packageName = $matches[1];
// remove leading @{$packageName}/ from an asset URL
$path = substr($path, strlen($packageName) + 2);
}
return $this->packages->getUrl($path, $packageName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment