diff --git a/src/Illuminate/Filesystem/FilesystemManager.php b/src/Illuminate/Filesystem/FilesystemManager.php index b54b510f224b..0dc9b97eaea1 100644 --- a/src/Illuminate/Filesystem/FilesystemManager.php +++ b/src/Illuminate/Filesystem/FilesystemManager.php @@ -1,5 +1,6 @@ getConfig($name); - - return $this->{"create".ucfirst($config['driver'])."Driver"}($config); + + if (isset($this->customCreators[$config['driver']])) + { + return $this->callCustomCreator($config); + } + else + { + return $this->{"create".ucfirst($config['driver'])."Driver"}($config); + } + } + + /** + * Call a custom driver creator. + * + * @param array $config + * @return \Illuminate\Contracts\Filesystem\Filesystem + */ + protected function callCustomCreator(array $config) + { + $driver = $this->customCreators[$config['driver']]($this->app, $config); + + if ($driver instanceof FilesystemInterface) + { + return $this->adapt($driver); + } + else + { + return $driver; + } } /** @@ -161,5 +196,19 @@ public function getDefaultDriver() { return $this->app['config']['filesystems.default']; } + + /** + * Register a custom driver creator Closure. + * + * @param string $driver + * @param \Closure $callback + * @return $this + */ + public function extend($driver, Closure $callback) + { + $this->customCreators[$driver] = $callback; + + return $this; + } }