Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,401 +0,0 @@
1
-<?php
2
-
3
-namespace Illuminate\Filesystem;
4
-
5
-use Closure;
6
-use Aws\S3\S3Client;
7
-use OpenCloud\Rackspace;
8
-use Illuminate\Support\Arr;
9
-use InvalidArgumentException;
10
-use League\Flysystem\AdapterInterface;
11
-use League\Flysystem\Sftp\SftpAdapter;
12
-use League\Flysystem\FilesystemInterface;
13
-use League\Flysystem\Cached\CachedAdapter;
14
-use League\Flysystem\Filesystem as Flysystem;
15
-use League\Flysystem\Adapter\Ftp as FtpAdapter;
16
-use League\Flysystem\Rackspace\RackspaceAdapter;
17
-use League\Flysystem\Adapter\Local as LocalAdapter;
18
-use League\Flysystem\AwsS3v3\AwsS3Adapter as S3Adapter;
19
-use League\Flysystem\Cached\Storage\Memory as MemoryStore;
20
-use Illuminate\Contracts\Filesystem\Factory as FactoryContract;
21
-
22
-/**
23
- * @mixin \Illuminate\Contracts\Filesystem\Filesystem
24
- */
25
-class FilesystemManager implements FactoryContract
26
-{
27
-    /**
28
-     * The application instance.
29
-     *
30
-     * @var \Illuminate\Contracts\Foundation\Application
31
-     */
32
-    protected $app;
33
-
34
-    /**
35
-     * The array of resolved filesystem drivers.
36
-     *
37
-     * @var array
38
-     */
39
-    protected $disks = [];
40
-
41
-    /**
42
-     * The registered custom driver creators.
43
-     *
44
-     * @var array
45
-     */
46
-    protected $customCreators = [];
47
-
48
-    /**
49
-     * Create a new filesystem manager instance.
50
-     *
51
-     * @param  \Illuminate\Contracts\Foundation\Application  $app
52
-     * @return void
53
-     */
54
-    public function __construct($app)
55
-    {
56
-        $this->app = $app;
57
-    }
58
-
59
-    /**
60
-     * Get a filesystem instance.
61
-     *
62
-     * @param  string|null  $name
63
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
64
-     */
65
-    public function drive($name = null)
66
-    {
67
-        return $this->disk($name);
68
-    }
69
-
70
-    /**
71
-     * Get a filesystem instance.
72
-     *
73
-     * @param  string|null  $name
74
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
75
-     */
76
-    public function disk($name = null)
77
-    {
78
-        $name = $name ?: $this->getDefaultDriver();
79
-
80
-        return $this->disks[$name] = $this->get($name);
81
-    }
82
-
83
-    /**
84
-     * Get a default cloud filesystem instance.
85
-     *
86
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
87
-     */
88
-    public function cloud()
89
-    {
90
-        $name = $this->getDefaultCloudDriver();
91
-
92
-        return $this->disks[$name] = $this->get($name);
93
-    }
94
-
95
-    /**
96
-     * Attempt to get the disk from the local cache.
97
-     *
98
-     * @param  string  $name
99
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
100
-     */
101
-    protected function get($name)
102
-    {
103
-        return $this->disks[$name] ?? $this->resolve($name);
104
-    }
105
-
106
-    /**
107
-     * Resolve the given disk.
108
-     *
109
-     * @param  string  $name
110
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
111
-     *
112
-     * @throws \InvalidArgumentException
113
-     */
114
-    protected function resolve($name)
115
-    {
116
-        $config = $this->getConfig($name);
117
-
118
-        if (isset($this->customCreators[$config['driver']])) {
119
-            return $this->callCustomCreator($config);
120
-        }
121
-
122
-        $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
123
-
124
-        if (method_exists($this, $driverMethod)) {
125
-            return $this->{$driverMethod}($config);
126
-        } else {
127
-            throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported.");
128
-        }
129
-    }
130
-
131
-    /**
132
-     * Call a custom driver creator.
133
-     *
134
-     * @param  array  $config
135
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
136
-     */
137
-    protected function callCustomCreator(array $config)
138
-    {
139
-        $driver = $this->customCreators[$config['driver']]($this->app, $config);
140
-
141
-        if ($driver instanceof FilesystemInterface) {
142
-            return $this->adapt($driver);
143
-        }
144
-
145
-        return $driver;
146
-    }
147
-
148
-    /**
149
-     * Create an instance of the local driver.
150
-     *
151
-     * @param  array  $config
152
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
153
-     */
154
-    public function createLocalDriver(array $config)
155
-    {
156
-        $permissions = $config['permissions'] ?? [];
157
-
158
-        $links = ($config['links'] ?? null) === 'skip'
159
-            ? LocalAdapter::SKIP_LINKS
160
-            : LocalAdapter::DISALLOW_LINKS;
161
-
162
-        return $this->adapt($this->createFlysystem(new LocalAdapter(
163
-            $config['root'], $config['lock'] ?? LOCK_EX, $links, $permissions
164
-        ), $config));
165
-    }
166
-
167
-    /**
168
-     * Create an instance of the ftp driver.
169
-     *
170
-     * @param  array  $config
171
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
172
-     */
173
-    public function createFtpDriver(array $config)
174
-    {
175
-        return $this->adapt($this->createFlysystem(
176
-            new FtpAdapter($config), $config
177
-        ));
178
-    }
179
-
180
-    /**
181
-     * Create an instance of the sftp driver.
182
-     *
183
-     * @param  array  $config
184
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
185
-     */
186
-    public function createSftpDriver(array $config)
187
-    {
188
-        return $this->adapt($this->createFlysystem(
189
-            new SftpAdapter($config), $config
190
-        ));
191
-    }
192
-
193
-    /**
194
-     * Create an instance of the Amazon S3 driver.
195
-     *
196
-     * @param  array  $config
197
-     * @return \Illuminate\Contracts\Filesystem\Cloud
198
-     */
199
-    public function createS3Driver(array $config)
200
-    {
201
-        $s3Config = $this->formatS3Config($config);
202
-
203
-        $root = $s3Config['root'] ?? null;
204
-
205
-        $options = $config['options'] ?? [];
206
-
207
-        return $this->adapt($this->createFlysystem(
208
-            new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $options), $config
209
-        ));
210
-    }
211
-
212
-    /**
213
-     * Format the given S3 configuration with the default options.
214
-     *
215
-     * @param  array  $config
216
-     * @return array
217
-     */
218
-    protected function formatS3Config(array $config)
219
-    {
220
-        $config += ['version' => 'latest'];
221
-
222
-        if ($config['key'] && $config['secret']) {
223
-            $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
224
-        }
225
-
226
-        return $config;
227
-    }
228
-
229
-    /**
230
-     * Create an instance of the Rackspace driver.
231
-     *
232
-     * @param  array  $config
233
-     * @return \Illuminate\Contracts\Filesystem\Cloud
234
-     */
235
-    public function createRackspaceDriver(array $config)
236
-    {
237
-        $client = new Rackspace($config['endpoint'], [
238
-            'username' => $config['username'], 'apiKey' => $config['key'],
239
-        ], $config['options'] ?? []);
240
-
241
-        $root = $config['root'] ?? null;
242
-
243
-        return $this->adapt($this->createFlysystem(
244
-            new RackspaceAdapter($this->getRackspaceContainer($client, $config), $root), $config
245
-        ));
246
-    }
247
-
248
-    /**
249
-     * Get the Rackspace Cloud Files container.
250
-     *
251
-     * @param  \OpenCloud\Rackspace  $client
252
-     * @param  array  $config
253
-     * @return \OpenCloud\ObjectStore\Resource\Container
254
-     */
255
-    protected function getRackspaceContainer(Rackspace $client, array $config)
256
-    {
257
-        $urlType = $config['url_type'] ?? null;
258
-
259
-        $store = $client->objectStoreService('cloudFiles', $config['region'], $urlType);
260
-
261
-        return $store->getContainer($config['container']);
262
-    }
263
-
264
-    /**
265
-     * Create a Flysystem instance with the given adapter.
266
-     *
267
-     * @param  \League\Flysystem\AdapterInterface  $adapter
268
-     * @param  array  $config
269
-     * @return \League\Flysystem\FilesystemInterface
270
-     */
271
-    protected function createFlysystem(AdapterInterface $adapter, array $config)
272
-    {
273
-        $cache = Arr::pull($config, 'cache');
274
-
275
-        $config = Arr::only($config, ['visibility', 'disable_asserts', 'url']);
276
-
277
-        if ($cache) {
278
-            $adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
279
-        }
280
-
281
-        return new Flysystem($adapter, count($config) > 0 ? $config : null);
282
-    }
283
-
284
-    /**
285
-     * Create a cache store instance.
286
-     *
287
-     * @param  mixed  $config
288
-     * @return \League\Flysystem\Cached\CacheInterface
289
-     *
290
-     * @throws \InvalidArgumentException
291
-     */
292
-    protected function createCacheStore($config)
293
-    {
294
-        if ($config === true) {
295
-            return new MemoryStore;
296
-        }
297
-
298
-        return new Cache(
299
-            $this->app['cache']->store($config['store']),
300
-            $config['prefix'] ?? 'flysystem',
301
-            $config['expire'] ?? null
302
-        );
303
-    }
304
-
305
-    /**
306
-     * Adapt the filesystem implementation.
307
-     *
308
-     * @param  \League\Flysystem\FilesystemInterface  $filesystem
309
-     * @return \Illuminate\Contracts\Filesystem\Filesystem
310
-     */
311
-    protected function adapt(FilesystemInterface $filesystem)
312
-    {
313
-        return new FilesystemAdapter($filesystem);
314
-    }
315
-
316
-    /**
317
-     * Set the given disk instance.
318
-     *
319
-     * @param  string  $name
320
-     * @param  mixed  $disk
321
-     * @return $this
322
-     */
323
-    public function set($name, $disk)
324
-    {
325
-        $this->disks[$name] = $disk;
326
-
327
-        return $this;
328
-    }
329
-
330
-    /**
331
-     * Get the filesystem connection configuration.
332
-     *
333
-     * @param  string  $name
334
-     * @return array
335
-     */
336
-    protected function getConfig($name)
337
-    {
338
-        return $this->app['config']["filesystems.disks.{$name}"];
339
-    }
340
-
341
-    /**
342
-     * Get the default driver name.
343
-     *
344
-     * @return string
345
-     */
346
-    public function getDefaultDriver()
347
-    {
348
-        return $this->app['config']['filesystems.default'];
349
-    }
350
-
351
-    /**
352
-     * Get the default cloud driver name.
353
-     *
354
-     * @return string
355
-     */
356
-    public function getDefaultCloudDriver()
357
-    {
358
-        return $this->app['config']['filesystems.cloud'];
359
-    }
360
-
361
-    /**
362
-     * Unset the given disk instances.
363
-     *
364
-     * @param  array|string  $disk
365
-     * @return $this
366
-     */
367
-    public function forgetDisk($disk)
368
-    {
369
-        foreach ((array) $disk as $diskName) {
370
-            unset($this->disks[$diskName]);
371
-        }
372
-
373
-        return $this;
374
-    }
375
-
376
-    /**
377
-     * Register a custom driver creator Closure.
378
-     *
379
-     * @param  string    $driver
380
-     * @param  \Closure  $callback
381
-     * @return $this
382
-     */
383
-    public function extend($driver, Closure $callback)
384
-    {
385
-        $this->customCreators[$driver] = $callback;
386
-
387
-        return $this;
388
-    }
389
-
390
-    /**
391
-     * Dynamically call the default driver instance.
392
-     *
393
-     * @param  string  $method
394
-     * @param  array   $parameters
395
-     * @return mixed
396
-     */
397
-    public function __call($method, $parameters)
398
-    {
399
-        return $this->disk()->$method(...$parameters);
400
-    }
401
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,401 @@
1
+<?php
2
+
3
+namespace Illuminate\Filesystem;
4
+
5
+use Closure;
6
+use Aws\S3\S3Client;
7
+use OpenCloud\Rackspace;
8
+use Illuminate\Support\Arr;
9
+use InvalidArgumentException;
10
+use League\Flysystem\AdapterInterface;
11
+use League\Flysystem\Sftp\SftpAdapter;
12
+use League\Flysystem\FilesystemInterface;
13
+use League\Flysystem\Cached\CachedAdapter;
14
+use League\Flysystem\Filesystem as Flysystem;
15
+use League\Flysystem\Adapter\Ftp as FtpAdapter;
16
+use League\Flysystem\Rackspace\RackspaceAdapter;
17
+use League\Flysystem\Adapter\Local as LocalAdapter;
18
+use League\Flysystem\AwsS3v3\AwsS3Adapter as S3Adapter;
19
+use League\Flysystem\Cached\Storage\Memory as MemoryStore;
20
+use Illuminate\Contracts\Filesystem\Factory as FactoryContract;
21
+
22
+/**
23
+ * @mixin \Illuminate\Contracts\Filesystem\Filesystem
24
+ */
25
+class FilesystemManager implements FactoryContract
26
+{
27
+    /**
28
+     * The application instance.
29
+     *
30
+     * @var \Illuminate\Contracts\Foundation\Application
31
+     */
32
+    protected $app;
33
+
34
+    /**
35
+     * The array of resolved filesystem drivers.
36
+     *
37
+     * @var array
38
+     */
39
+    protected $disks = [];
40
+
41
+    /**
42
+     * The registered custom driver creators.
43
+     *
44
+     * @var array
45
+     */
46
+    protected $customCreators = [];
47
+
48
+    /**
49
+     * Create a new filesystem manager instance.
50
+     *
51
+     * @param  \Illuminate\Contracts\Foundation\Application  $app
52
+     * @return void
53
+     */
54
+    public function __construct($app)
55
+    {
56
+        $this->app = $app;
57
+    }
58
+
59
+    /**
60
+     * Get a filesystem instance.
61
+     *
62
+     * @param  string|null  $name
63
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
64
+     */
65
+    public function drive($name = null)
66
+    {
67
+        return $this->disk($name);
68
+    }
69
+
70
+    /**
71
+     * Get a filesystem instance.
72
+     *
73
+     * @param  string|null  $name
74
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
75
+     */
76
+    public function disk($name = null)
77
+    {
78
+        $name = $name ?: $this->getDefaultDriver();
79
+
80
+        return $this->disks[$name] = $this->get($name);
81
+    }
82
+
83
+    /**
84
+     * Get a default cloud filesystem instance.
85
+     *
86
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
87
+     */
88
+    public function cloud()
89
+    {
90
+        $name = $this->getDefaultCloudDriver();
91
+
92
+        return $this->disks[$name] = $this->get($name);
93
+    }
94
+
95
+    /**
96
+     * Attempt to get the disk from the local cache.
97
+     *
98
+     * @param  string  $name
99
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
100
+     */
101
+    protected function get($name)
102
+    {
103
+        return $this->disks[$name] ?? $this->resolve($name);
104
+    }
105
+
106
+    /**
107
+     * Resolve the given disk.
108
+     *
109
+     * @param  string  $name
110
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
111
+     *
112
+     * @throws \InvalidArgumentException
113
+     */
114
+    protected function resolve($name)
115
+    {
116
+        $config = $this->getConfig($name);
117
+
118
+        if (isset($this->customCreators[$config['driver']])) {
119
+            return $this->callCustomCreator($config);
120
+        }
121
+
122
+        $driverMethod = 'create'.ucfirst($config['driver']).'Driver';
123
+
124
+        if (method_exists($this, $driverMethod)) {
125
+            return $this->{$driverMethod}($config);
126
+        } else {
127
+            throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported.");
128
+        }
129
+    }
130
+
131
+    /**
132
+     * Call a custom driver creator.
133
+     *
134
+     * @param  array  $config
135
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
136
+     */
137
+    protected function callCustomCreator(array $config)
138
+    {
139
+        $driver = $this->customCreators[$config['driver']]($this->app, $config);
140
+
141
+        if ($driver instanceof FilesystemInterface) {
142
+            return $this->adapt($driver);
143
+        }
144
+
145
+        return $driver;
146
+    }
147
+
148
+    /**
149
+     * Create an instance of the local driver.
150
+     *
151
+     * @param  array  $config
152
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
153
+     */
154
+    public function createLocalDriver(array $config)
155
+    {
156
+        $permissions = $config['permissions'] ?? [];
157
+
158
+        $links = ($config['links'] ?? null) === 'skip'
159
+            ? LocalAdapter::SKIP_LINKS
160
+            : LocalAdapter::DISALLOW_LINKS;
161
+
162
+        return $this->adapt($this->createFlysystem(new LocalAdapter(
163
+            $config['root'], $config['lock'] ?? LOCK_EX, $links, $permissions
164
+        ), $config));
165
+    }
166
+
167
+    /**
168
+     * Create an instance of the ftp driver.
169
+     *
170
+     * @param  array  $config
171
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
172
+     */
173
+    public function createFtpDriver(array $config)
174
+    {
175
+        return $this->adapt($this->createFlysystem(
176
+            new FtpAdapter($config), $config
177
+        ));
178
+    }
179
+
180
+    /**
181
+     * Create an instance of the sftp driver.
182
+     *
183
+     * @param  array  $config
184
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
185
+     */
186
+    public function createSftpDriver(array $config)
187
+    {
188
+        return $this->adapt($this->createFlysystem(
189
+            new SftpAdapter($config), $config
190
+        ));
191
+    }
192
+
193
+    /**
194
+     * Create an instance of the Amazon S3 driver.
195
+     *
196
+     * @param  array  $config
197
+     * @return \Illuminate\Contracts\Filesystem\Cloud
198
+     */
199
+    public function createS3Driver(array $config)
200
+    {
201
+        $s3Config = $this->formatS3Config($config);
202
+
203
+        $root = $s3Config['root'] ?? null;
204
+
205
+        $options = $config['options'] ?? [];
206
+
207
+        return $this->adapt($this->createFlysystem(
208
+            new S3Adapter(new S3Client($s3Config), $s3Config['bucket'], $root, $options), $config
209
+        ));
210
+    }
211
+
212
+    /**
213
+     * Format the given S3 configuration with the default options.
214
+     *
215
+     * @param  array  $config
216
+     * @return array
217
+     */
218
+    protected function formatS3Config(array $config)
219
+    {
220
+        $config += ['version' => 'latest'];
221
+
222
+        if ($config['key'] && $config['secret']) {
223
+            $config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
224
+        }
225
+
226
+        return $config;
227
+    }
228
+
229
+    /**
230
+     * Create an instance of the Rackspace driver.
231
+     *
232
+     * @param  array  $config
233
+     * @return \Illuminate\Contracts\Filesystem\Cloud
234
+     */
235
+    public function createRackspaceDriver(array $config)
236
+    {
237
+        $client = new Rackspace($config['endpoint'], [
238
+            'username' => $config['username'], 'apiKey' => $config['key'],
239
+        ], $config['options'] ?? []);
240
+
241
+        $root = $config['root'] ?? null;
242
+
243
+        return $this->adapt($this->createFlysystem(
244
+            new RackspaceAdapter($this->getRackspaceContainer($client, $config), $root), $config
245
+        ));
246
+    }
247
+
248
+    /**
249
+     * Get the Rackspace Cloud Files container.
250
+     *
251
+     * @param  \OpenCloud\Rackspace  $client
252
+     * @param  array  $config
253
+     * @return \OpenCloud\ObjectStore\Resource\Container
254
+     */
255
+    protected function getRackspaceContainer(Rackspace $client, array $config)
256
+    {
257
+        $urlType = $config['url_type'] ?? null;
258
+
259
+        $store = $client->objectStoreService('cloudFiles', $config['region'], $urlType);
260
+
261
+        return $store->getContainer($config['container']);
262
+    }
263
+
264
+    /**
265
+     * Create a Flysystem instance with the given adapter.
266
+     *
267
+     * @param  \League\Flysystem\AdapterInterface  $adapter
268
+     * @param  array  $config
269
+     * @return \League\Flysystem\FilesystemInterface
270
+     */
271
+    protected function createFlysystem(AdapterInterface $adapter, array $config)
272
+    {
273
+        $cache = Arr::pull($config, 'cache');
274
+
275
+        $config = Arr::only($config, ['visibility', 'disable_asserts', 'url']);
276
+
277
+        if ($cache) {
278
+            $adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
279
+        }
280
+
281
+        return new Flysystem($adapter, count($config) > 0 ? $config : null);
282
+    }
283
+
284
+    /**
285
+     * Create a cache store instance.
286
+     *
287
+     * @param  mixed  $config
288
+     * @return \League\Flysystem\Cached\CacheInterface
289
+     *
290
+     * @throws \InvalidArgumentException
291
+     */
292
+    protected function createCacheStore($config)
293
+    {
294
+        if ($config === true) {
295
+            return new MemoryStore;
296
+        }
297
+
298
+        return new Cache(
299
+            $this->app['cache']->store($config['store']),
300
+            $config['prefix'] ?? 'flysystem',
301
+            $config['expire'] ?? null
302
+        );
303
+    }
304
+
305
+    /**
306
+     * Adapt the filesystem implementation.
307
+     *
308
+     * @param  \League\Flysystem\FilesystemInterface  $filesystem
309
+     * @return \Illuminate\Contracts\Filesystem\Filesystem
310
+     */
311
+    protected function adapt(FilesystemInterface $filesystem)
312
+    {
313
+        return new FilesystemAdapter($filesystem);
314
+    }
315
+
316
+    /**
317
+     * Set the given disk instance.
318
+     *
319
+     * @param  string  $name
320
+     * @param  mixed  $disk
321
+     * @return $this
322
+     */
323
+    public function set($name, $disk)
324
+    {
325
+        $this->disks[$name] = $disk;
326
+
327
+        return $this;
328
+    }
329
+
330
+    /**
331
+     * Get the filesystem connection configuration.
332
+     *
333
+     * @param  string  $name
334
+     * @return array
335
+     */
336
+    protected function getConfig($name)
337
+    {
338
+        return $this->app['config']["filesystems.disks.{$name}"];
339
+    }
340
+
341
+    /**
342
+     * Get the default driver name.
343
+     *
344
+     * @return string
345
+     */
346
+    public function getDefaultDriver()
347
+    {
348
+        return $this->app['config']['filesystems.default'];
349
+    }
350
+
351
+    /**
352
+     * Get the default cloud driver name.
353
+     *
354
+     * @return string
355
+     */
356
+    public function getDefaultCloudDriver()
357
+    {
358
+        return $this->app['config']['filesystems.cloud'];
359
+    }
360
+
361
+    /**
362
+     * Unset the given disk instances.
363
+     *
364
+     * @param  array|string  $disk
365
+     * @return $this
366
+     */
367
+    public function forgetDisk($disk)
368
+    {
369
+        foreach ((array) $disk as $diskName) {
370
+            unset($this->disks[$diskName]);
371
+        }
372
+
373
+        return $this;
374
+    }
375
+
376
+    /**
377
+     * Register a custom driver creator Closure.
378
+     *
379
+     * @param  string    $driver
380
+     * @param  \Closure  $callback
381
+     * @return $this
382
+     */
383
+    public function extend($driver, Closure $callback)
384
+    {
385
+        $this->customCreators[$driver] = $callback;
386
+
387
+        return $this;
388
+    }
389
+
390
+    /**
391
+     * Dynamically call the default driver instance.
392
+     *
393
+     * @param  string  $method
394
+     * @param  array   $parameters
395
+     * @return mixed
396
+     */
397
+    public function __call($method, $parameters)
398
+    {
399
+        return $this->disk()->$method(...$parameters);
400
+    }
401
+}