diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index 8dd7f9f8ec26..f04d08149062 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -112,17 +112,18 @@ protected function get($name) protected function resolve($name) { $config = $this->getConfig($name); + $name = $config['driver'] ?? $name; - if (isset($this->customCreators[$config['driver']])) { + if (isset($this->customCreators[$name])) { return $this->callCustomCreator($config); } - $driverMethod = 'create'.ucfirst($config['driver']).'Driver'; + $driverMethod = 'create'.ucfirst($name).'Driver'; if (method_exists($this, $driverMethod)) { return $this->{$driverMethod}($config); } else { - throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported."); + throw new InvalidArgumentException("Driver [{$name}] is not supported."); } } @@ -298,7 +299,7 @@ public function set($name, $disk) */ protected function getConfig($name) { - return $this->app['config']["filesystems.disks.{$name}"]; + return $this->app['config']["filesystems.disks.{$name}"] ?: []; } /** diff --git a/tests/Filesystem/FilesystemManagerTest.php b/tests/Filesystem/FilesystemManagerTest.php new file mode 100644 index 000000000000..81f9262b6414 --- /dev/null +++ b/tests/Filesystem/FilesystemManagerTest.php @@ -0,0 +1,23 @@ +expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('Driver [unsupported-disk] is not supported.'); + + $filesystem = new FilesystemManager(tap(new Application, function ($app) { + $app['config'] = ['filesystems.disks.unsupported-disk' => null]; + })); + + $filesystem->disk('unsupported-disk'); + } +}