Adding support for setting global config filtering function; A bit improving logs
This commit is contained in:
parent
e2f7d07342
commit
4105ad80e0
|
@ -4,6 +4,7 @@ use Exception;
|
||||||
|
|
||||||
$GLOBALS['CONFIG_BASE_DIRS'] = array();
|
$GLOBALS['CONFIG_BASE_DIRS'] = array();
|
||||||
$GLOBALS['CONFIG_INIT_WORKER_FUNC'] = null;
|
$GLOBALS['CONFIG_INIT_WORKER_FUNC'] = null;
|
||||||
|
$GLOBALS['CONFIG_FILTER_FN'] = null;
|
||||||
|
|
||||||
task('config_worker', function(array $args)
|
task('config_worker', function(array $args)
|
||||||
{
|
{
|
||||||
|
@ -55,8 +56,9 @@ function config_map_base_dir($file, $normalized = false, $strict = true, $dirs =
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function config_real_path($rel_path, $strict = true)
|
function config_real_path($rel_path, $strict = true, $dirs = null)
|
||||||
{
|
{
|
||||||
|
if(!is_array($dirs))
|
||||||
$dirs = config_base_dirs();
|
$dirs = config_base_dirs();
|
||||||
foreach($dirs as $dir)
|
foreach($dirs as $dir)
|
||||||
if(is_file($dir . '/' . $rel_path))
|
if(is_file($dir . '/' . $rel_path))
|
||||||
|
@ -80,7 +82,22 @@ function config_set_worker_init_fn($fn)
|
||||||
|
|
||||||
function config_scan_files()
|
function config_scan_files()
|
||||||
{
|
{
|
||||||
return scan_files_rec(config_base_dirs(), array('conf.js'));
|
$files = scan_files_rec(config_base_dirs(), array('conf.js'));
|
||||||
|
return config_filter_files($files);
|
||||||
|
}
|
||||||
|
|
||||||
|
function config_filter_files(array $files)
|
||||||
|
{
|
||||||
|
global $CONFIG_FILTER_FN;
|
||||||
|
if($CONFIG_FILTER_FN != null)
|
||||||
|
$files = call_user_func($CONFIG_FILTER_FN, $files);
|
||||||
|
return $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function config_set_files_filter_fn(callable $fn)
|
||||||
|
{
|
||||||
|
global $CONFIG_FILTER_FN;
|
||||||
|
$CONFIG_FILTER_FN = $fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function config_pack_bundle(array $cache_entries, $use_lz4 = false, $use_config_refs = false)
|
function config_pack_bundle(array $cache_entries, $use_lz4 = false, $use_config_refs = false)
|
||||||
|
@ -338,7 +355,7 @@ function config_fetch_ex(
|
||||||
list($result, $total_stales) = _config_fetch_cache_ex($results_by_job);
|
list($result, $total_stales) = _config_fetch_cache_ex($results_by_job);
|
||||||
|
|
||||||
if($verbose)
|
if($verbose)
|
||||||
echo "Miss/Hit: $total_stales/" . sizeof($result->all) . "\n";
|
echo "Miss/All: $total_stales/" . sizeof($result->all) . "\n";
|
||||||
|
|
||||||
config_save_includes_map($includes_map, $includes_map_file);
|
config_save_includes_map($includes_map, $includes_map_file);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue