public function UnmanagedFilesService::getDirs in Fancy File Delete 2.0.x
Answer a list of directories to include/exclude.
2 calls to UnmanagedFilesService::getDirs()
- UnmanagedFilesService::getChosenDirs in src/
UnmanagedFilesService.php - Gets a list of chosen directories to delete unmanaged files from. Defaults to all directories if no choice was previously made.
- UnmanagedFilesService::setChosenDirs in src/
UnmanagedFilesService.php - Set a list of chosen directories from which to delete unmanaged files from.
File
- src/
UnmanagedFilesService.php, line 172
Class
- UnmanagedFilesService
- Class UnmanagedFilesService.
Namespace
Drupal\fancy_file_deleteCode
public function getDirs() {
$public_dir = $this->state
->get('file_public_path', 'sites/default/files');
$private_dir = $this->fileSystem
->realpath("private://");
// If the private path is a sub-path of the public path, exclude it.
$exclude_paths = [];
if (!empty($private_dir) && strpos($private_dir, $public_dir) === FALSE) {
$exclude_paths[] = $private_dir;
}
// Get all files from default standard file dir.
$directories = [
'public://',
];
$directories = array_merge($directories, $this
->getSubDirectories($public_dir, 'public://', $exclude_paths));
// Get all files from the private file directory.
if (!empty($private_dir)) {
// If the public path is a sub-path of the private path, exclude it.
$exclude_paths = [];
if (!empty($public_dir) && strpos($public_dir, $private_dir) === FALSE) {
$exclude_paths[] = $public_dir;
}
$directories[] = 'private://';
$directories = array_merge($directories, $this
->getSubDirectories($private_dir, 'private://', $exclude_paths));
}
natsort($directories);
return array_values($directories);
}