1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Lenevor Framework |
5
|
|
|
* |
6
|
|
|
* LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the new BSD license that is bundled |
9
|
|
|
* with this package in the file license.md. |
10
|
|
|
* It is also available through the world-wide-web at this URL: |
11
|
|
|
* https://lenevor.com/license |
12
|
|
|
* If you did not receive a copy of the license and are unable to |
13
|
|
|
* obtain it through the world-wide-web, please send an email |
14
|
|
|
* to [email protected] so we can send you a copy immediately. |
15
|
|
|
* |
16
|
|
|
* @package Lenevor |
17
|
|
|
* @subpackage Base |
18
|
|
|
* @link https://lenevor.com |
19
|
|
|
* @copyright Copyright (c) 2019 - 2023 Alexander Campo <[email protected]> |
20
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause New BSD license or see https://lenevor.com/license or see /license.md |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace Syscodes\Components\Filesystem; |
24
|
|
|
|
25
|
|
|
use Syscodes\Components\Support\ServiceProvider; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* For loading the classes from the container of services. |
29
|
|
|
*/ |
30
|
|
|
class FilesystemServiceProvider extends ServiceProvider |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Register the service provider. |
34
|
|
|
* |
35
|
|
|
* @return void |
36
|
|
|
*/ |
37
|
|
|
public function register() |
38
|
|
|
{ |
39
|
|
|
$this->registerLocalFilesystem(); |
40
|
|
|
|
41
|
|
|
$this->registerFilesystemManager(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Register the local filesystem implementation. |
46
|
|
|
* |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
protected function registerLocalFilesystem() |
50
|
|
|
{ |
51
|
|
|
$this->app->singleton('files', fn () => new Filesystem); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Register the driver based filesystem. |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
protected function registerFilesystemManager() |
60
|
|
|
{ |
61
|
|
|
$this->registerManager(); |
62
|
|
|
|
63
|
|
|
$this->app->singleton('filesystem.disk', fn ($app) => $app['filesystem']->disk($this->getDefaultDriver())); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Register the filesystem manager. |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
|
|
protected function registerManager() |
73
|
|
|
{ |
74
|
|
|
$this->app->singleton('filesystem', fn ($app) => new FilesystemManager($app)); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get the default file driver. |
79
|
|
|
* |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
protected function getDefaultDriver() |
83
|
|
|
{ |
84
|
|
|
return $this->app['config']['filesystems.default']; |
85
|
|
|
} |
86
|
|
|
} |