Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to support multiple directories #1143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/LfmStorageRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@ public function __construct($storage_path, $helper)

public function __call($function_name, $arguments)
{
// TODO: check function exists
return $this->disk->$function_name($this->path, ...$arguments);
if ($function_name == 'directories') {
$directories = $this->disk->directories($this->path, ...$arguments);
$config = $this->helper->config('private_folder_name');

if(method_exists(app()->make($config), 'userAuthDirs')) {
return $this->getAuthDirectories($directories, app()->make($config)->userAuthDirs());
} else {
return $directories;
}

} else {
// TODO: check function exists
return $this->disk->$function_name($this->path, ...$arguments);
}
}

public function rootPath()
Expand Down Expand Up @@ -62,4 +74,20 @@ public function extension()
setlocale(LC_ALL, 'en_US.UTF-8');
return pathinfo($this->path, PATHINFO_EXTENSION);
}

public function getAuthDirectories($directories, $auth_dirs)
{
$check = $directories;

if(count($auth_dirs)){
// remove unauthorized directories
foreach($check as $i => $directory) {
if(!in_array($directory, $auth_dirs)){
unset($directories[$i]);
}
}
}

return $directories;
}
}