Created
February 5, 2018 13:20
-
-
Save alongosz/dc881b8be0fac613ac40720d6d8ebab2 to your computer and use it in GitHub Desktop.
eZ Design namespace for assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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