1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Micro framework package. |
7
|
|
|
* |
8
|
|
|
* (c) Stanislau Komar <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Micro\Plugin\Filesystem\Adapter\Local; |
15
|
|
|
|
16
|
|
|
use Micro\Component\DependencyInjection\Container; |
17
|
|
|
use Micro\Framework\Kernel\Plugin\ConfigurableInterface; |
18
|
|
|
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface; |
19
|
|
|
use Micro\Framework\Kernel\Plugin\PluginConfigurationTrait; |
20
|
|
|
use Micro\Framework\Kernel\Plugin\PluginDependedInterface; |
21
|
|
|
use Micro\Plugin\Filesystem\Adapter\Local\Business\Adapter\AdapterFactory; |
22
|
|
|
use Micro\Plugin\Filesystem\Adapter\Local\Configuration\FilesystemLocalAdapterPluginConfigurationInterface; |
23
|
|
|
use Micro\Plugin\Filesystem\Adapter\Local\Decorator\LocalFilesystemFacadeDecorator; |
24
|
|
|
use Micro\Plugin\Filesystem\Business\Adapter\AdapterFactoryInterface; |
25
|
|
|
use Micro\Plugin\Filesystem\Business\FS\FsFactory; |
26
|
|
|
use Micro\Plugin\Filesystem\Business\FS\FsFactoryInterface; |
27
|
|
|
use Micro\Plugin\Filesystem\Facade\FilesystemFacadeInterface; |
28
|
|
|
use Micro\Plugin\Filesystem\FilesystemPlugin; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @method FilesystemLocalAdapterPluginConfigurationInterface configuration() |
32
|
|
|
*/ |
33
|
|
|
class FilesystemLocalAdapterPlugin implements DependencyProviderInterface, ConfigurableInterface, PluginDependedInterface |
34
|
|
|
{ |
35
|
|
|
use PluginConfigurationTrait; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritDoc} |
39
|
|
|
*/ |
40
|
1 |
|
public function provideDependencies(Container $container): void |
41
|
|
|
{ |
42
|
1 |
|
$container->decorate(FilesystemFacadeInterface::class, function ( |
43
|
1 |
|
FilesystemFacadeInterface $filesystemFacade |
44
|
1 |
|
): FilesystemFacadeInterface { |
45
|
1 |
|
return $this->createFacadeDecorator($filesystemFacade); |
46
|
1 |
|
}); |
47
|
|
|
} |
48
|
|
|
|
49
|
1 |
|
public function getDependedPlugins(): iterable |
50
|
|
|
{ |
51
|
1 |
|
return [ |
52
|
1 |
|
FilesystemPlugin::class, |
53
|
1 |
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return FsFactoryInterface |
58
|
|
|
*/ |
59
|
1 |
|
protected function createFsFactory(): FsFactoryInterface |
60
|
|
|
{ |
61
|
1 |
|
return new FsFactory( |
62
|
1 |
|
$this->configuration(), |
63
|
1 |
|
$this->createAdapterFactory() |
64
|
1 |
|
); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return AdapterFactoryInterface |
69
|
|
|
*/ |
70
|
1 |
|
protected function createAdapterFactory(): AdapterFactoryInterface |
71
|
|
|
{ |
72
|
1 |
|
return new AdapterFactory(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param FilesystemFacadeInterface $filesystemFacade |
77
|
|
|
* |
78
|
|
|
* @return FilesystemFacadeInterface |
79
|
|
|
*/ |
80
|
1 |
|
protected function createFacadeDecorator(FilesystemFacadeInterface $filesystemFacade): FilesystemFacadeInterface |
81
|
|
|
{ |
82
|
1 |
|
return new LocalFilesystemFacadeDecorator( |
83
|
1 |
|
$filesystemFacade, |
84
|
1 |
|
$this->createFsFactory(), |
85
|
1 |
|
$this->configuration() |
86
|
1 |
|
); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|