getWebDir function

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-12-27 16:44:14 +01:00
parent 00412d1c8c
commit 5008eb8f85
No known key found for this signature in database
GPG Key ID: FB5ACEED51955BF8
1 changed files with 19 additions and 15 deletions

View File

@ -102,21 +102,7 @@ class SCSSCacher {
$fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS));
$path = implode('/', $path);
$webDir = null;
// Detect if path is within an app path
$app_paths = $this->config->getSystemValue('apps_paths');
if (!empty($app_paths)) {
foreach ($app_paths as $app_path) {
if (strpos($path, $app_path["path"]) === 0) {
$webDir = $app_path["url"].str_replace($app_path["path"], '', $path);
break;
}
}
}
if (is_null($webDir)) {
$webDir = substr($path, strlen($this->serverRoot));
}
$webDir = $this->getWebDir($path);
try {
$folder = $this->appData->getFolder($app);
@ -322,4 +308,22 @@ class SCSSCacher {
private function prependBaseurlPrefix($cssFile) {
return md5($this->urlGenerator->getBaseUrl()) . '-' . $cssFile;
}
/**
* Prepend hashed base url to the css file
* @param string $path the css file path
* @return string the webDir
*/
private function getWebDir($path) {
// Detect if path is within an app path
$app_paths = $this->config->getSystemValue('apps_paths');
if (!empty($app_paths)) {
foreach ($app_paths as $app_path) {
if (strpos($path, $app_path["path"]) === 0) {
return $app_path["url"].str_replace($app_path["path"], '', $path);
}
}
}
return substr($path, strlen($this->serverRoot));
}
}