Projekt

Obecné

Profil

Stáhnout (1.71 KB) Statistiky
| Větev: | Revize:
1
<?php
2

    
3
namespace Illuminate\Filesystem;
4

    
5
use Illuminate\Support\ServiceProvider;
6

    
7
class FilesystemServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Register the service provider.
11
     *
12
     * @return void
13
     */
14
    public function register()
15
    {
16
        $this->registerNativeFilesystem();
17

    
18
        $this->registerFlysystem();
19
    }
20

    
21
    /**
22
     * Register the native filesystem implementation.
23
     *
24
     * @return void
25
     */
26
    protected function registerNativeFilesystem()
27
    {
28
        $this->app->singleton('files', function () {
29
            return new Filesystem;
30
        });
31
    }
32

    
33
    /**
34
     * Register the driver based filesystem.
35
     *
36
     * @return void
37
     */
38
    protected function registerFlysystem()
39
    {
40
        $this->registerManager();
41

    
42
        $this->app->singleton('filesystem.disk', function () {
43
            return $this->app['filesystem']->disk($this->getDefaultDriver());
44
        });
45

    
46
        $this->app->singleton('filesystem.cloud', function () {
47
            return $this->app['filesystem']->disk($this->getCloudDriver());
48
        });
49
    }
50

    
51
    /**
52
     * Register the filesystem manager.
53
     *
54
     * @return void
55
     */
56
    protected function registerManager()
57
    {
58
        $this->app->singleton('filesystem', function () {
59
            return new FilesystemManager($this->app);
60
        });
61
    }
62

    
63
    /**
64
     * Get the default file driver.
65
     *
66
     * @return string
67
     */
68
    protected function getDefaultDriver()
69
    {
70
        return $this->app['config']['filesystems.default'];
71
    }
72

    
73
    /**
74
     * Get the default cloud based file driver.
75
     *
76
     * @return string
77
     */
78
    protected function getCloudDriver()
79
    {
80
        return $this->app['config']['filesystems.cloud'];
81
    }
82
}
(5-5/6)