-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFieldtypeOembedConfig.php
More file actions
68 lines (55 loc) · 1.63 KB
/
FieldtypeOembedConfig.php
File metadata and controls
68 lines (55 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* COPYRIGHT NOTICE
* Copyright (c) 2023 Neue Rituale GbR
* @author NR <code@neuerituale.com>
*/
namespace ProcessWire;
class FieldtypeOembedConfig extends ModuleConfig
{
/**
* @return array
* @throws WireException
*/
public function getDefaults(): array {
// get schedules from Lazy Cron
/** @var LazyCron $lazyCronInstance */
$lazyCronInstance = $this->modules->get('LazyCron');
$getTimeFuncsFunction = function(){ return $this->timeFuncs; };
return [
'cronSchedule' => 604800,
'timeFuncs' => $getTimeFuncsFunction->call($lazyCronInstance),
'customProviders' => '',
];
}
/**
* @return InputfieldWrapper
*/
public function getInputfields(): InputfieldWrapper {
$inputfields = parent::getInputfields();
/** @var InputfieldSelect */
$inputfields->add([
'type' => 'Select',
'name' => 'cronSchedule',
'label' => 'Cron Schedule',
'description' => __('If selected, the cron will refresh the expires oembed data in all oembed fields.'),
'options' => $this->get('timeFuncs')
]);
// validate Custom Providers (JSON)
if(!empty($this->customProviders)) {
$customProviders = json_decode($this->customProviders,JSON_OBJECT_AS_ARRAY);
if(!is_array($customProviders)) {
wire()->error('Invalid JSON in field Custom Providers (JSON)');
}
}
/** @var InputfieldTextarea */
$inputfields->add([
'type' => 'Textarea',
'name' => 'customProviders',
'label' => 'Custom Providers (JSON)',
'rows' => 20,
'description' => __('Add custom Providers here. For information on how to add custom providers please refer to the documentation.'),
]);
return $inputfields;
}
}