Fix SCSS usage in apps

* fix the web root detection of the ResourceLocator for apps

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2017-02-24 18:29:05 -06:00 committed by Roeland Jago Douma
parent c38f87e799
commit 3ca9d53194
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 32 additions and 1 deletions

View File

@ -117,7 +117,38 @@ abstract class ResourceLocator {
*/
protected function append($root, $file, $webRoot = null, $throw = true) {
if (!$webRoot) {
$webRoot = $this->mapping[$root];
$tmpRoot = $root;
/*
* traverse the potential web roots upwards in the path
*
* example:
* - root: /srv/www/apps/myapp
* - available mappings: ['/srv/www']
*
* First we check if a mapping for /srv/www/apps/myapp is available,
* then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
* valid web root
*/
do {
if (isset($this->mapping[$tmpRoot])) {
$webRoot = $this->mapping[$tmpRoot];
break;
}
if ($tmpRoot === '/') {
$webRoot = '';
$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
'app' => 'lib',
'root' => $root,
'file' => $file,
'webRoot' => $webRoot,
'throw' => $throw ? 'true' : 'false'
]);
break;
}
$tmpRoot = dirname($tmpRoot);
} while(true);
}
$this->resources[] = array($root, $webRoot, $file);