|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Spiral Framework package. |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Spiral\Storage\Config\DTO\FileSystemInfo\Aws; |
|
13
|
|
|
|
|
14
|
|
|
use Spiral\Storage\Config\DTO\FileSystemInfo\FileSystemInfo; |
|
15
|
|
|
use Spiral\Storage\Config\DTO\FileSystemInfo\SpecificConfigurableFileSystemInfo; |
|
16
|
|
|
use Spiral\Storage\Resolver\AwsS3Resolver; |
|
17
|
|
|
|
|
18
|
|
|
class AwsS3Info extends FileSystemInfo implements SpecificConfigurableFileSystemInfo |
|
19
|
|
|
{ |
|
20
|
|
|
public const BUCKET_KEY = 'bucket'; |
|
21
|
|
|
public const CLIENT_KEY = 'client'; |
|
22
|
|
|
public const PATH_PREFIX_KEY = 'path-prefix'; |
|
23
|
|
|
|
|
24
|
|
|
protected const FILE_SYSTEM_INFO_TYPE = 'awsS3'; |
|
25
|
|
|
|
|
26
|
|
|
protected const REQUIRED_OPTIONS = [ |
|
27
|
|
|
self::BUCKET_KEY => self::STRING_TYPE, |
|
28
|
|
|
self::CLIENT_KEY => self::MIXED_TYPE, |
|
29
|
|
|
]; |
|
30
|
|
|
|
|
31
|
|
|
protected const ADDITIONAL_OPTIONS = [ |
|
32
|
|
|
self::PATH_PREFIX_KEY => self::STRING_TYPE, |
|
33
|
|
|
self::VISIBILITY_KEY => self::ARRAY_TYPE, |
|
34
|
|
|
]; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $resolver = AwsS3Resolver::class; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var AwsVisibilityConverter|null |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $visibilityConverter = null; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @inheritDoc |
|
48
|
|
|
*/ |
|
49
|
|
|
public function constructSpecific(array $info): void |
|
50
|
|
|
{ |
|
51
|
|
|
if ($this->hasOption(static::VISIBILITY_KEY)) { |
|
52
|
|
|
$this->visibilityConverter = new AwsVisibilityConverter($this->getOption(static::VISIBILITY_KEY)); |
|
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Get prepared visibility converter |
|
58
|
|
|
* |
|
59
|
|
|
* @return mixed|null |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getVisibilityConverter() |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->visibilityConverter instanceof AwsVisibilityConverter |
|
64
|
|
|
? $this->visibilityConverter->getConverter() |
|
65
|
|
|
: null; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get S3 client |
|
70
|
|
|
* |
|
71
|
|
|
* @return mixed|null |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getClient() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->getOption(static::CLIENT_KEY); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|