-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilesystemServiceProvider.js
49 lines (37 loc) · 1.18 KB
/
filesystemServiceProvider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const ServiceProvider = require('@ostro/support/serviceProvider');
const FilesystemManager = require('./filesystemManager');
const Filesystem = require('./filesystem');
class filesystemServiceProvider extends ServiceProvider {
register() {
this.registerNativeFilesystem();
this.registerFlysystem();
}
registerNativeFilesystem() {
this.$app.singleton('files', function() {
return new Filesystem;
});
}
registerFlysystem() {
this.registerManager();
this.$app.singleton('filesystem.disk', ($app) => {
return $app['filesystem'].disk(this.getDefaultDriver());
});
this.$app.singleton('filesystem.cloud', ($app) => {
return $app['filesystem'].disk(this.getCloudDriver());
});
}
registerManager() {
this.$app.singleton('filesystem', function($app) {
return new FilesystemManager($app);
});
}
getDefaultDriver() {
return this.$app['config']['filesystems.default'];
}
getCloudDriver() {
return this.$app['config']['filesystems.cloud'];
}
boot() {
}
}
module.exports = filesystemServiceProvider