From 54c5bd8d4f3d0593eff158371d1ed9dbb5a74d65 Mon Sep 17 00:00:00 2001 From: Franco Gilio Date: Mon, 30 Apr 2018 17:09:41 -0300 Subject: [PATCH 1/2] Add unset() method in FilesystemManager I'm building a multi tenant system and I had to add this method to be able to update the disk's roots dynamically when switching tenants. For exampel, in this app we need to switch tenants when running queue jobs. The disk config is cached, so this method needs to be called manually before making changes to the config. After the disk is used again the new config is cached automatically. Here is an example of a system with disks for photos and videos: ```php // First we unset the disks app('filesystem')->unset(['photos', 'videos']); // Apply the tenant's slug as the disk path root Config::set('filesystems.disks.photos.root', $this->currentTenant->slug); Config::set('filesystems.disks.videos.root', $this->currentTenant->slug); ``` --- src/Illuminate/Filesystem/FilesystemManager.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index 9505a3a3884e..38b4d0f11f1f 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -325,6 +325,19 @@ public function set($name, $disk) $this->disks[$name] = $disk; } + /** + * Unset the given disks instances. + * + * @param array $names + * @return void + */ + public function unset($names) + { + foreach ($names as $name) { + unset($this->disks[$name]); + } + } + /** * Get the filesystem connection configuration. * From 2c968e14ffa3e95769e8c94b338a1319a3e65eee Mon Sep 17 00:00:00 2001 From: Franco Gilio Date: Mon, 30 Apr 2018 17:16:17 -0300 Subject: [PATCH 2/2] Remove whitespace --- src/Illuminate/Filesystem/FilesystemManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index 38b4d0f11f1f..a5e32c613dca 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -337,7 +337,7 @@ public function unset($names) unset($this->disks[$name]); } } - + /** * Get the filesystem connection configuration. *