|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AnyCloud\Form; |
|
4
|
|
|
|
|
5
|
|
|
use Zend\Form\Element; |
|
|
|
|
|
|
6
|
|
|
use Zend\Form\Fieldset; |
|
|
|
|
|
|
7
|
|
|
use Zend\Form\Form; |
|
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
class ConfigForm extends Form |
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
protected $globalSettings; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Initialize the configuration form. |
|
16
|
|
|
*/ |
|
17
|
|
|
public function init() |
|
18
|
|
|
{ |
|
19
|
|
|
$this->addAdapter(); |
|
20
|
|
|
$this->addS3('aws', 'Amazon S3 Storage'); |
|
21
|
|
|
$this->addAzure(); |
|
22
|
|
|
$this->addGoogle(); |
|
23
|
|
|
$this->addS3('digital_ocean', 'DigitalOcean Spaces', 'DigitalOcean'); |
|
24
|
|
|
$this->addS3('scaleway', 'Scaleway Object Storage', 'Scaleway'); |
|
25
|
|
|
$this->addRackspace(); |
|
26
|
|
|
$this->addDropbox(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Set configuration settings. |
|
31
|
|
|
*/ |
|
32
|
|
|
public function setGlobalSettings($globalSettings) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->globalSettings = $globalSettings; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Add adapter drop-down options to configuration form. |
|
39
|
|
|
*/ |
|
40
|
|
|
private function addAdapter() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->add([ |
|
43
|
|
|
'name' => 'anycloud_adapter', |
|
44
|
|
|
'type' => Fieldset::class, |
|
45
|
|
|
'options' => [ |
|
46
|
|
|
'label' => 'Any Cloud Adapter', |
|
47
|
|
|
], |
|
48
|
|
|
'attributes' => [ |
|
49
|
|
|
'id' => 'adapter-fieldset', |
|
50
|
|
|
], |
|
51
|
|
|
]); |
|
52
|
|
|
$adapterFieldset = $this->get('anycloud_adapter'); |
|
53
|
|
|
$adapterFieldset->add([ |
|
54
|
|
|
'name' => 'adapter', |
|
55
|
|
|
'type' => Element\Select::class, |
|
|
|
|
|
|
56
|
|
|
'options' => [ |
|
57
|
|
|
'label' => 'Cloud Service Adapter: ', |
|
58
|
|
|
'value_options' => [ |
|
59
|
|
|
'default' => 'Omeka Default (local server)', |
|
60
|
|
|
'aws' => 'Amazon S3 Storage', |
|
61
|
|
|
'azure' => 'Microsoft Azure Storage', |
|
62
|
|
|
'google' => 'Google Cloud Storage', |
|
63
|
|
|
'digital_ocean' => 'DigitalOcean Spaces', |
|
64
|
|
|
'scaleway' => 'Scaleway Object Storage', |
|
65
|
|
|
'rackspace' => 'Rackspace Files', |
|
66
|
|
|
'dropbox' => 'Dropbox', |
|
67
|
|
|
], |
|
68
|
|
|
], |
|
69
|
|
|
'attributes' => [ |
|
70
|
|
|
'id' => 'adapter', |
|
71
|
|
|
], |
|
72
|
|
|
]); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Add any Amazon S3-based storage adapter. |
|
77
|
|
|
* |
|
78
|
|
|
* @param string $id ID used to identify adapter |
|
79
|
|
|
* @param string $name Full name of adapter |
|
80
|
|
|
* @param string|null $label Abbreviated name used for form labels |
|
81
|
|
|
*/ |
|
82
|
|
|
private function addS3($id, $name, $label = null) |
|
83
|
|
|
{ |
|
84
|
|
|
$label = $label === null ? $label : $label.' '; |
|
85
|
|
|
$this->add([ |
|
86
|
|
|
'name' => 'anycloud_'.$id, |
|
87
|
|
|
'type' => Fieldset::class, |
|
88
|
|
|
'options' => [ |
|
89
|
|
|
'label' => $name, |
|
90
|
|
|
], |
|
91
|
|
|
'attributes' => [ |
|
92
|
|
|
'class' => $id.' fieldset', |
|
93
|
|
|
], |
|
94
|
|
|
]); |
|
95
|
|
|
$awsFieldset = $this->get('anycloud_'.$id); |
|
96
|
|
|
$awsFieldset->add([ |
|
97
|
|
|
'name' => $id.'_key', |
|
98
|
|
|
'type' => Element\Text::class, |
|
|
|
|
|
|
99
|
|
|
'options' => [ |
|
100
|
|
|
'label' => $label.'AWS Key', |
|
101
|
|
|
], |
|
102
|
|
|
'attributes' => [ |
|
103
|
|
|
'id' => $id.'_key', |
|
104
|
|
|
], |
|
105
|
|
|
]); |
|
106
|
|
|
$awsFieldset->add([ |
|
107
|
|
|
'name' => $id.'_secret_key', |
|
108
|
|
|
'type' => Element\Text::class, |
|
109
|
|
|
'options' => [ |
|
110
|
|
|
'label' => $label.'AWS Secret Key', |
|
111
|
|
|
], |
|
112
|
|
|
'attributes' => [ |
|
113
|
|
|
'id' => $id.'_secret_key', |
|
114
|
|
|
'cols' => '100', |
|
115
|
|
|
], |
|
116
|
|
|
]); |
|
117
|
|
|
$awsFieldset->add([ |
|
118
|
|
|
'name' => $id.'_bucket', |
|
119
|
|
|
'type' => Element\Text::class, |
|
120
|
|
|
'options' => [ |
|
121
|
|
|
'label' => $label.'AWS Bucket', |
|
122
|
|
|
], |
|
123
|
|
|
'attributes' => [ |
|
124
|
|
|
'id' => $id.'_bucket', |
|
125
|
|
|
], |
|
126
|
|
|
]); |
|
127
|
|
|
$awsFieldset->add([ |
|
128
|
|
|
'name' => $id.'_region', |
|
129
|
|
|
'type' => Element\Text::class, |
|
130
|
|
|
'options' => [ |
|
131
|
|
|
'label' => $label.'AWS Region', |
|
132
|
|
|
], |
|
133
|
|
|
'attributes' => [ |
|
134
|
|
|
'id' => $id.'_region', |
|
135
|
|
|
], |
|
136
|
|
|
]); |
|
137
|
|
|
$awsFieldset->add([ |
|
138
|
|
|
'name' => $id.'_endpoint', |
|
139
|
|
|
'type' => Element\Text::class, |
|
140
|
|
|
'options' => [ |
|
141
|
|
|
'label' => $label.'AWS Endpoint', |
|
142
|
|
|
'info' => 'Can usually leave blank unless you have a custom endpoint set up. See https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region', |
|
143
|
|
|
], |
|
144
|
|
|
'attributes' => [ |
|
145
|
|
|
'id' => $id.'_endpoint', |
|
146
|
|
|
], |
|
147
|
|
|
]); |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Add Microsoft Azure Storage options to configuration form. |
|
152
|
|
|
*/ |
|
153
|
|
|
private function addAzure() |
|
154
|
|
|
{ |
|
155
|
|
|
$this->add([ |
|
156
|
|
|
'name' => 'anycloud_azure', |
|
157
|
|
|
'type' => Fieldset::class, |
|
158
|
|
|
'options' => [ |
|
159
|
|
|
'label' => 'Microsoft Azure Storage', |
|
160
|
|
|
], |
|
161
|
|
|
'attributes' => [ |
|
162
|
|
|
'class' => 'azure fieldset', |
|
163
|
|
|
], |
|
164
|
|
|
]); |
|
165
|
|
|
$azureFieldset = $this->get('anycloud_azure'); |
|
166
|
|
|
$azureFieldset->add([ |
|
167
|
|
|
'name' => 'azure_account_name', |
|
168
|
|
|
'type' => Element\Text::class, |
|
169
|
|
|
'options' => [ |
|
170
|
|
|
'label' => 'Azure Account Name', |
|
171
|
|
|
], |
|
172
|
|
|
'attributes' => [ |
|
173
|
|
|
'id' => 'azure_account_name', |
|
174
|
|
|
], |
|
175
|
|
|
]); |
|
176
|
|
|
$azureFieldset->add([ |
|
177
|
|
|
'name' => 'azure_account_key', |
|
178
|
|
|
'type' => Element\Text::class, |
|
179
|
|
|
'options' => [ |
|
180
|
|
|
'label' => 'Azure Account Key', |
|
181
|
|
|
], |
|
182
|
|
|
'attributes' => [ |
|
183
|
|
|
'id' => 'azure_account_key', |
|
184
|
|
|
], |
|
185
|
|
|
]); |
|
186
|
|
|
$azureFieldset->add([ |
|
187
|
|
|
'name' => 'azure_container_name', |
|
188
|
|
|
'type' => Element\Text::class, |
|
189
|
|
|
'options' => [ |
|
190
|
|
|
'label' => 'Azure Container Name', |
|
191
|
|
|
], |
|
192
|
|
|
'attributes' => [ |
|
193
|
|
|
'id' => 'azure_container_name', |
|
194
|
|
|
], |
|
195
|
|
|
]); |
|
196
|
|
|
$azureFieldset->add([ |
|
197
|
|
|
'name' => 'azure_endpoint', |
|
198
|
|
|
'type' => Element\Text::class, |
|
199
|
|
|
'options' => [ |
|
200
|
|
|
'label' => 'Azure Endpoint', |
|
201
|
|
|
'info' => 'Can usually leave blank unless you have a custom endpoint set up', |
|
202
|
|
|
], |
|
203
|
|
|
'attributes' => [ |
|
204
|
|
|
'id' => 'azure_endpoint', |
|
205
|
|
|
], |
|
206
|
|
|
]); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* Add Google Cloud Storage options to configuration form. |
|
211
|
|
|
*/ |
|
212
|
|
|
private function addGoogle() |
|
213
|
|
|
{ |
|
214
|
|
|
$this->add([ |
|
215
|
|
|
'name' => 'anycloud_google', |
|
216
|
|
|
'type' => Fieldset::class, |
|
217
|
|
|
'options' => [ |
|
218
|
|
|
'label' => 'Google Cloud Storage', |
|
219
|
|
|
], |
|
220
|
|
|
'attributes' => [ |
|
221
|
|
|
'class' => 'google fieldset', |
|
222
|
|
|
], |
|
223
|
|
|
]); |
|
224
|
|
|
$googleFieldset = $this->get('anycloud_google'); |
|
225
|
|
|
$googleFieldset->add([ |
|
226
|
|
|
'name' => 'google_project_id', |
|
227
|
|
|
'type' => Element\Text::class, |
|
228
|
|
|
'options' => [ |
|
229
|
|
|
'label' => 'Google Project ID', |
|
230
|
|
|
], |
|
231
|
|
|
'attributes' => [ |
|
232
|
|
|
'id' => 'google_project_id', |
|
233
|
|
|
], |
|
234
|
|
|
]); |
|
235
|
|
|
$googleFieldset->add([ |
|
236
|
|
|
'name' => 'google_bucket_name', |
|
237
|
|
|
'type' => Element\Text::class, |
|
238
|
|
|
'options' => [ |
|
239
|
|
|
'label' => 'Google Bucket Name', |
|
240
|
|
|
], |
|
241
|
|
|
'attributes' => [ |
|
242
|
|
|
'id' => 'google_bucket_name', |
|
243
|
|
|
], |
|
244
|
|
|
]); |
|
245
|
|
|
$googleFieldset->add([ |
|
246
|
|
|
'name' => 'google_credentials_path', |
|
247
|
|
|
'type' => Element\Text::class, |
|
248
|
|
|
'options' => [ |
|
249
|
|
|
'label' => 'Google Credentials Path', |
|
250
|
|
|
'info' => 'Replace {CONFIG} with the name of your Google credentials file stored at the listed path', |
|
251
|
|
|
'value' => '/src/Service/File/Adapter/Google/{CONFIG}.json', |
|
252
|
|
|
], |
|
253
|
|
|
'attributes' => [ |
|
254
|
|
|
'id' => 'google_credentials_path', |
|
255
|
|
|
], |
|
256
|
|
|
]); |
|
257
|
|
|
$googleFieldset->add([ |
|
258
|
|
|
'name' => 'google_storage_uri', |
|
259
|
|
|
'type' => Element\Text::class, |
|
260
|
|
|
'options' => [ |
|
261
|
|
|
'label' => 'Google Storage URI', |
|
262
|
|
|
'info' => 'You can usually leave this as the default unless you have tweaked other settings', |
|
263
|
|
|
'value' => 'https://storage.googleapis.com', |
|
264
|
|
|
], |
|
265
|
|
|
'attributes' => [ |
|
266
|
|
|
'id' => 'google_storage_uri', |
|
267
|
|
|
], |
|
268
|
|
|
]); |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* Add Rackspace Files options to configuration form. |
|
273
|
|
|
*/ |
|
274
|
|
|
private function addRackspace() |
|
275
|
|
|
{ |
|
276
|
|
|
$this->add([ |
|
277
|
|
|
'name' => 'anycloud_rackspace', |
|
278
|
|
|
'type' => Fieldset::class, |
|
279
|
|
|
'options' => [ |
|
280
|
|
|
'label' => 'Rackspace Files', |
|
281
|
|
|
], |
|
282
|
|
|
'attributes' => [ |
|
283
|
|
|
'class' => 'rackspace fieldset', |
|
284
|
|
|
], |
|
285
|
|
|
]); |
|
286
|
|
|
$rackspaceFieldset = $this->get('anycloud_rackspace'); |
|
287
|
|
|
$rackspaceFieldset->add([ |
|
288
|
|
|
'name' => 'rackspace_identity_endpoint', |
|
289
|
|
|
'type' => Element\Text::class, |
|
290
|
|
|
'options' => [ |
|
291
|
|
|
'label' => 'Rackspace Identity Endpoint', |
|
292
|
|
|
'info' => 'Valid options include “US_IDENTITY_ENDPOINT” and “UK_IDENTITY_ENDPOINT”', |
|
293
|
|
|
], |
|
294
|
|
|
'attributes' => [ |
|
295
|
|
|
'id' => 'rackspace_identity_endpoint', |
|
296
|
|
|
], |
|
297
|
|
|
]); |
|
298
|
|
|
$rackspaceFieldset->add([ |
|
299
|
|
|
'name' => 'rackspace_username', |
|
300
|
|
|
'type' => Element\Text::class, |
|
301
|
|
|
'options' => [ |
|
302
|
|
|
'label' => 'Rackspace Username', |
|
303
|
|
|
], |
|
304
|
|
|
'attributes' => [ |
|
305
|
|
|
'id' => 'rackspace_username', |
|
306
|
|
|
], |
|
307
|
|
|
]); |
|
308
|
|
|
$rackspaceFieldset->add([ |
|
309
|
|
|
'name' => 'rackspace_password', |
|
310
|
|
|
'type' => Element\Text::class, |
|
311
|
|
|
'options' => [ |
|
312
|
|
|
'label' => 'Rackspace Password', |
|
313
|
|
|
], |
|
314
|
|
|
'attributes' => [ |
|
315
|
|
|
'id' => 'rackspace_password', |
|
316
|
|
|
], |
|
317
|
|
|
]); |
|
318
|
|
|
$rackspaceFieldset->add([ |
|
319
|
|
|
'name' => 'rackspace_container', |
|
320
|
|
|
'type' => Element\Text::class, |
|
321
|
|
|
'options' => [ |
|
322
|
|
|
'label' => 'Rackspace Container Name', |
|
323
|
|
|
], |
|
324
|
|
|
'attributes' => [ |
|
325
|
|
|
'id' => 'rackspace_container', |
|
326
|
|
|
], |
|
327
|
|
|
]); |
|
328
|
|
|
$rackspaceFieldset->add([ |
|
329
|
|
|
'name' => 'rackspace_region', |
|
330
|
|
|
'type' => Element\Text::class, |
|
331
|
|
|
'options' => [ |
|
332
|
|
|
'label' => 'Rackspace Region', |
|
333
|
|
|
], |
|
334
|
|
|
'attributes' => [ |
|
335
|
|
|
'id' => 'rackspace_region', |
|
336
|
|
|
], |
|
337
|
|
|
]); |
|
338
|
|
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* Add Dropbox options to configuration form. |
|
342
|
|
|
*/ |
|
343
|
|
|
private function addDropbox() |
|
344
|
|
|
{ |
|
345
|
|
|
$this->add([ |
|
346
|
|
|
'name' => 'anycloud_dropbox', |
|
347
|
|
|
'type' => Fieldset::class, |
|
348
|
|
|
'options' => [ |
|
349
|
|
|
'label' => 'Dropbox', |
|
350
|
|
|
], |
|
351
|
|
|
'attributes' => [ |
|
352
|
|
|
'class' => 'dropbox fieldset', |
|
353
|
|
|
], |
|
354
|
|
|
]); |
|
355
|
|
|
$dropboxFieldset = $this->get('anycloud_dropbox'); |
|
356
|
|
|
$dropboxFieldset->add([ |
|
357
|
|
|
'name' => 'dropbox_access_token', |
|
358
|
|
|
'type' => Element\Text::class, |
|
359
|
|
|
'options' => [ |
|
360
|
|
|
'label' => 'Dropbox Access Token', |
|
361
|
|
|
], |
|
362
|
|
|
'attributes' => [ |
|
363
|
|
|
'id' => 'dropbox_access_token', |
|
364
|
|
|
], |
|
365
|
|
|
]); |
|
366
|
|
|
} |
|
367
|
|
|
} |
|
368
|
|
|
|
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