mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-25 15:01:16 +02:00
Pulled hidden file logic out of the app config and into application code
This commit is contained in:
@@ -76,32 +76,23 @@ return [
|
||||
'reverse_sort' => Helpers::env('REVERSE_SORT', false),
|
||||
|
||||
/**
|
||||
* File used by 'hidden_files' to define the list of hidden files.
|
||||
* File containing hidden file definitions. Will be merged with definitions
|
||||
* from the 'hidden_files' configuration option.
|
||||
*
|
||||
* Default value: '.hidden'
|
||||
*/
|
||||
'hidden_files_list' => Helpers::env('HIDDEN_FILES_LIST', '.hidden'),
|
||||
|
||||
/**
|
||||
* Array of files that will be hidden from the listing. Supports glob
|
||||
* patterns (e.g. *.txt, file.ya?ml, etc.).
|
||||
* Array of hidden file definitions. Will be merged with definitions in the
|
||||
* file definned in the 'hidden_files_list' configuration option. Supports
|
||||
* glob patterns (e.g. *.txt, file.{yml,yaml}, etc.).
|
||||
*
|
||||
* By defualt this will look for a '.hidden' file in the app root directory.
|
||||
* If found, each line of this file will be used as an ignore pattern.
|
||||
*
|
||||
* Default value: Array loaded from '.hidden' file if present, otherwise
|
||||
* an empty array ([])
|
||||
* Default value: []
|
||||
*/
|
||||
'hidden_files' => static function (ContainerInterface $container): array {
|
||||
if (! is_readable($container->get('hidden_files_list'))) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return file(
|
||||
$container->get('hidden_files_list'),
|
||||
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES
|
||||
);
|
||||
},
|
||||
'hidden_files' => [
|
||||
// ...
|
||||
],
|
||||
|
||||
/**
|
||||
* Whether or not to hide application files/directories form the listing.
|
||||
|
@@ -84,7 +84,11 @@ class FinderFactory
|
||||
{
|
||||
return Collection::make(
|
||||
$this->container->get('hidden_files')
|
||||
)->when($this->container->get('hide_app_files'), static function (Collection $collection) {
|
||||
)->when(is_readable($this->container->get('hidden_files_list')), function (Collection $collection) {
|
||||
return $collection->merge(
|
||||
file($this->container->get('hidden_files_list'), FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
|
||||
);
|
||||
})->when($this->container->get('hide_app_files'), static function (Collection $collection) {
|
||||
return $collection->merge(self::APP_FILES);
|
||||
})->unique();
|
||||
}
|
||||
|
Reference in New Issue
Block a user