thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.37k stars 831 forks source link

Make method mountFilesystem public anew #1286

Closed Rikijs closed 3 years ago

Rikijs commented 3 years ago

Feature Request

Q A Comment
New Feature yes for v2 exposed feature of v1 library
BC Break probably not since at the moment it is not accessible from users' code

Scenario / Use-case

mountFilesystem() should be public method as in v1 version of FlySystem. It allows for name keys for different filesystems which is useful.

Usage example

$data_dir_stored = $this->params->get('data_dir_stored');
$data_dir_shared = $this->params->get('data_dir_shared');
$adapter_stored = new LocalFilesystemAdapter($data_dir_stored);
$adapter_shared = new LocalFilesystemAdapter($data_dir_shared);
$filesystem_stored = new Filesystem($adapter_stored);
$filesystem_shared = new Filesystem($adapter_shared);

$this->mountManager->mountFilesystem('stored', $filesystem_stored);
$this->mountManager->mountFilesystem('shared', $filesystem_shared);
$path_stored = 'stored://' . $storable_file_path;
$path_shared = 'shared://' . $shareable_file_path;
//dump($path_stored);
//dump($path_shared);

$exists_from = $this->mountManager->fileExists($path_stored);
$exists_to = $this->mountManager->fileExists($path_shared);
//dump($exists_from);
//dump($exists_to);

if ($exists_from && !$exists_to)
{
    // move file
    $this->mountManager->copy($path_stored, $path_shared);
}

Summary

Please make mountFilesystem() public anew.

Rikijs commented 3 years ago

Ping @frankdejonge . Please consider making $mountManager->mountFilesystem() public.

frankdejonge commented 3 years ago

@Rikijs what's the use-case that requires you to dynamically register filesystems? Btw, pinging after 15 hours is just rude. It's an open source project, what do you expect?

Rikijs commented 3 years ago

I am sorry about the ping. :( I regret it and apologize.

One use case is - previously written (for FlySystem v1) code would work with minimal modification.

There are 3 base paths in my application. For stored files, for deleted files and for shared files. All 3 are working with local filesystem. There is file traffic between those 3 nodes. Full paths are constructed dynamically. Does it count as good use case?

Your comment makes me think i misused the API of FlySystem v1 and could have done without KEYs... If there is a better way - please share your take on it.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.