small rework for https://github.com/opnsense/core/issues/2379 to make sure ui_devtools can overwrite the file_exists() behaviour

This commit is contained in:
Ad Schellevis 2018-05-15 12:08:05 +02:00
parent bdb125e06c
commit 57267ca994
2 changed files with 11 additions and 1 deletions

View File

@ -52,7 +52,7 @@ $di->set('view', function () use ($config) {
));
// register additional volt template functions
$volt->getCompiler()->addFunction('theme_file_or_default', 'view_fetch_themed_filename');
$volt->getCompiler()->addFunction('file_exists', 'file_exists');
$volt->getCompiler()->addFunction('file_exists', 'view_file_exists');
return $volt;
},

View File

@ -23,6 +23,16 @@ function view_fetch_themed_filename($url, $theme)
return $url; // not found, return source
}
/**
* check if file exists, wrapper around file_exists() so services.php can define other implementation for local testing
* @param string $filename to check
* @return boolean
*/
function view_file_exists($filename)
{
return file_exists($filename);
}
try {
/**
* Read the configuration