public function resolvePublicWebPath($path)
{
//if its a external path?
if (strpos($path, '://') !== false) {
return $path;
}
$webDir = realpath($this->rootDir . '/../web') . '/';
if ($path && '@' === $path[0]) {
try {
$path = $this->resolveWebPath($path);
$path = substr($path, strpos($path, '/') + 1);
} catch (BundleNotFoundException $e) {
}
}
if (file_exists($webDir . $path)) {
return $path;
}
if ($this->requestStack->getMasterRequest()) {
//do we need to add app_dev.php/ or something?
$prefix = substr($this->requestStack->getMasterRequest()->getBaseUrl(), strlen($this->requestStack->getMasterRequest()->getBasePath()));
if (false !== $prefix) {
if ($prefix && ($prefix = substr($prefix, 1))) {
$path = $prefix . '/' . $path;
}
}
}
return $path;
}