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\Decorator; |
15
|
|
|
|
16
|
|
|
use League\Flysystem\FilesystemOperator; |
17
|
|
|
use Micro\Plugin\Filesystem\Adapter\Local\Configuration\FilesystemLocalAdapterPluginConfigurationInterface; |
18
|
|
|
use Micro\Plugin\Filesystem\Business\FS\FsFactoryInterface; |
19
|
|
|
use Micro\Plugin\Filesystem\Configuration\FilesystemPluginConfigurationInterface; |
20
|
|
|
use Micro\Plugin\Filesystem\Facade\FilesystemFacadeInterface; |
21
|
|
|
|
22
|
|
|
class LocalFilesystemFacadeDecorator implements FilesystemFacadeInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @param FilesystemFacadeInterface $filesystemFacade |
26
|
|
|
* @param FsFactoryInterface $fsFactory |
27
|
|
|
* @param FilesystemPluginConfigurationInterface $pluginConfiguration |
28
|
|
|
*/ |
29
|
2 |
|
public function __construct( |
30
|
|
|
private readonly FilesystemFacadeInterface $filesystemFacade, |
31
|
|
|
private readonly FsFactoryInterface $fsFactory, |
32
|
|
|
private readonly FilesystemPluginConfigurationInterface $pluginConfiguration |
33
|
|
|
) { |
34
|
2 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $adapterName |
38
|
|
|
* |
39
|
|
|
* @return FilesystemOperator |
40
|
|
|
*/ |
41
|
2 |
|
public function createFsOperator(string $adapterName = FilesystemPluginConfigurationInterface::ADAPTER_DEFAULT): FilesystemOperator |
42
|
|
|
{ |
43
|
2 |
|
if (FilesystemLocalAdapterPluginConfigurationInterface::ADAPTER_NAME !== $this->pluginConfiguration->getAdapterType($adapterName)) { |
44
|
1 |
|
return $this->filesystemFacade->createFsOperator($adapterName); |
45
|
|
|
} |
46
|
|
|
|
47
|
1 |
|
return $this->fsFactory->create($adapterName); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|