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