1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace diecoding\aws\s3\commands; |
4
|
|
|
|
5
|
|
|
use Aws\ResultInterface; |
6
|
|
|
use diecoding\aws\s3\base\commands\ExecutableCommand; |
7
|
|
|
use diecoding\aws\s3\base\commands\traits\Async; |
8
|
|
|
use diecoding\aws\s3\base\commands\traits\Options; |
9
|
|
|
use diecoding\aws\s3\interfaces\commands\Asynchronous; |
10
|
|
|
use diecoding\aws\s3\interfaces\commands\HasBucket; |
11
|
|
|
use diecoding\aws\s3\interfaces\commands\PlainCommand; |
12
|
|
|
use GuzzleHttp\Promise\PromiseInterface; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class DeleteCommand |
16
|
|
|
* |
17
|
|
|
* @method ResultInterface|PromiseInterface execute() |
18
|
|
|
* |
19
|
|
|
* @package diecoding\aws\s3\commands |
20
|
|
|
*/ |
21
|
|
|
class DeleteCommand extends ExecutableCommand implements PlainCommand, HasBucket, Asynchronous |
22
|
|
|
{ |
23
|
|
|
use Async; |
24
|
|
|
use Options; |
25
|
|
|
|
26
|
|
|
/** @var array */ |
27
|
|
|
protected $args = []; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @return string |
31
|
|
|
*/ |
32
|
|
|
public function getBucket(): string |
33
|
|
|
{ |
34
|
|
|
return $this->args['Bucket'] ?? ''; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param string $name |
39
|
|
|
* |
40
|
|
|
* @return $this |
41
|
|
|
*/ |
42
|
|
|
public function inBucket(string $name) |
43
|
|
|
{ |
44
|
|
|
$this->args['Bucket'] = $name; |
45
|
|
|
|
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
public function getFilename(): string |
53
|
|
|
{ |
54
|
|
|
return $this->args['Key'] ?? ''; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param string $filename |
59
|
|
|
* |
60
|
|
|
* @return $this |
61
|
|
|
*/ |
62
|
|
|
public function byFilename(string $filename) |
63
|
|
|
{ |
64
|
|
|
$this->args['Key'] = $filename; |
65
|
|
|
|
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getVersionId(): string |
73
|
|
|
{ |
74
|
|
|
return $this->args['VersionId'] ?? ''; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param string $versionId |
79
|
|
|
* |
80
|
|
|
* @return $this |
81
|
|
|
*/ |
82
|
|
|
public function withVersionId(string $versionId) |
83
|
|
|
{ |
84
|
|
|
$this->args['VersionId'] = $versionId; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @internal used by the handlers |
91
|
|
|
* |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public function getName(): string |
95
|
|
|
{ |
96
|
|
|
return 'DeleteObject'; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @internal used by the handlers |
101
|
|
|
* |
102
|
|
|
* @return array |
103
|
|
|
*/ |
104
|
|
|
public function toArgs(): array |
105
|
|
|
{ |
106
|
|
|
return array_replace($this->options, $this->args); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|