1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AnyCloud\Service\File\Store; |
4
|
|
|
|
5
|
|
|
use AnyCloud\File\Store\Flysystem; |
6
|
|
|
use Interop\Container\ContainerInterface; |
7
|
|
|
use Laminas\ServiceManager\Factory\FactoryInterface; |
|
|
|
|
8
|
|
|
use League\Flysystem\Filesystem; |
9
|
|
|
use League\Flysystem\FilesystemAdapter; |
10
|
|
|
use Omeka\File\Store\StoreInterface; |
11
|
|
|
|
12
|
|
|
abstract class AbstractFlysystemFactory implements FactoryInterface |
13
|
|
|
{ |
14
|
|
|
abstract protected function getConfigKey(): string; |
15
|
|
|
|
16
|
|
|
abstract protected function getFilesystemAdapter(array $config): FilesystemAdapter; |
17
|
|
|
|
18
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) |
19
|
|
|
{ |
20
|
|
|
$config = $this->getConfig($container); |
21
|
|
|
$store = $this->getStore($config); |
22
|
|
|
|
23
|
|
|
return $store; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
protected function getConfig(ContainerInterface $container) |
27
|
|
|
{ |
28
|
|
|
$config = $container->get('Config'); |
29
|
|
|
|
30
|
|
|
$configKey = $this->getConfigKey(); |
31
|
|
|
if (isset($config['file_store'][$configKey])) { |
32
|
|
|
return $config['file_store'][$configKey]; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$settings = $container->get('Omeka\Settings'); |
36
|
|
|
$db_settings = $settings->get("anycloud_$configKey", []); |
37
|
|
|
$adapter_config = []; |
38
|
|
|
$configKeyQuoted = preg_quote($configKey); |
39
|
|
|
foreach ($db_settings as $key => $value) { |
40
|
|
|
$new_key = preg_replace("/^{$configKeyQuoted}_/", '', $key); |
41
|
|
|
$adapter_config[$new_key] = $value; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return $adapter_config; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
protected function getStore(array $config): StoreInterface |
48
|
|
|
{ |
49
|
|
|
$adapter = $this->getFilesystemAdapter($config); |
50
|
|
|
$filesystem = new Filesystem($adapter); |
51
|
|
|
$store = new Flysystem($filesystem); |
52
|
|
|
|
53
|
|
|
return $store; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths