customize view_fetch_themed_filename() to support multiple document roots

This commit is contained in:
Ad Schellevis 2018-03-06 21:20:07 +01:00
parent 14659ecc2b
commit e580ad27f5
1 changed files with 24 additions and 0 deletions

View File

@ -28,6 +28,30 @@
*/
error_reporting(E_ALL);
/**
* search for a themed filename or return distribution standard
* @param string $url relative url
* @param array $theme theme name
* @return string
*/
function view_fetch_themed_filename($url, $theme)
{
$search_pattern = array(
"/themes/{$theme}/build/",
"/"
);
foreach ($search_pattern as $pattern) {
foreach (\Phalcon\DI\FactoryDefault::getDefault()->get('config')->application->docroot as $path) {
$filename = "{$path}{$pattern}{$url}";
if (file_exists($filename)) {
return str_replace("//", "/", "/ui{$pattern}{$url}");
}
}
}
return $url; // not found, return source
}
try {
/**
* Read the configuration