1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AnyCloud\Service\File\Store; |
4
|
|
|
|
5
|
|
|
use AnyCloud\File\Store\AnyCloud; |
6
|
|
|
use AnyCloud\Service\File\Adapter; |
7
|
|
|
use AnyCloud\Traits\CommonTrait; |
8
|
|
|
use League\Flysystem\Filesystem; |
9
|
|
|
use Interop\Container\ContainerInterface; |
|
|
|
|
10
|
|
|
use Zend\ServiceManager\Factory\FactoryInterface; |
|
|
|
|
11
|
|
|
|
12
|
|
|
class AnyCloudFactory implements FactoryInterface |
13
|
|
|
{ |
14
|
|
|
use CommonTrait; |
15
|
|
|
|
16
|
|
|
protected $options; |
17
|
|
|
private $filesystem; |
18
|
|
|
private $uri; |
19
|
|
|
private $tempUri; |
20
|
|
|
private $adapter; |
21
|
|
|
const AWS_BASED = ['aws', 'digital_ocean', 'scaleway']; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param ContainerInterface $serviceLocator |
25
|
|
|
* @param string $requestedName |
26
|
|
|
* @param array|null $options |
27
|
|
|
* |
28
|
|
|
* @return AnyCloud|object |
29
|
|
|
*/ |
30
|
|
|
public function __invoke(ContainerInterface $serviceLocator, $requestedName, array $options = null) |
31
|
|
|
{ |
32
|
|
|
$this->options = $serviceLocator->get('Omeka\Settings'); |
33
|
|
|
$this->createFilesystem(); |
34
|
|
|
$this->createUri(); |
35
|
|
|
|
36
|
|
|
return new AnyCloud($this->filesystem, $this->options, $this->uri, $this->adapter); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Create the Filesystem object |
41
|
|
|
*/ |
42
|
|
|
private function createFilesystem() |
43
|
|
|
{ |
44
|
|
|
if(in_array($this->getAdapter(), self::AWS_BASED)) { |
45
|
|
|
$adapter = new Adapter\AwsAdapter; |
46
|
|
|
$this->adapter = $adapter->createAdapter($this->options); |
47
|
|
|
} else { |
48
|
|
|
$adapter = new Adapter\AzureAdapter; |
49
|
|
|
$this->adapter = $adapter->createAdapter($this->options); |
50
|
|
|
$this->tempUri = $adapter->getUri(); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->filesystem = new Filesystem($this->adapter); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Create URI for file |
58
|
|
|
*/ |
59
|
|
|
private function createUri() |
60
|
|
|
{ |
61
|
|
|
if(in_array($this->getAdapter(), self::AWS_BASED)) { |
62
|
|
|
$this->uri = dirname($this->filesystem->getAdapter()->getClient()->getObjectUrl($this->getSetting('bucket'), |
63
|
|
|
$this->getSetting('key'))); |
64
|
|
|
} else { |
65
|
|
|
$this->uri = $this->tempUri; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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