-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathReportFieldTypes.php
More file actions
89 lines (74 loc) · 1.96 KB
/
ReportFieldTypes.php
File metadata and controls
89 lines (74 loc) · 1.96 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
namespace DrupalCodeBuilder\Task;
use MutableTypedData\Definition\OptionSetDefininitionInterface;
use DrupalCodeBuilder\Task\Report\SectionReportInterface;
/**
* Task handler for reporting on field type data.
*/
class ReportFieldTypes extends ReportHookDataFolder implements OptionSetDefininitionInterface, SectionReportInterface {
use OptionsProviderTrait;
use SectionReportSimpleCountTrait;
/**
* The sanity level this task requires to operate.
*/
protected $sanity_level = 'component_data_processed';
/**
* The name of the method providing an array of options as $value => $label.
*/
protected static $optionsMethod = 'listFieldTypesOptions';
/**
* The data.
*/
protected $fieldTypesData;
/**
* {@inheritdoc}
*/
public function getInfo(): array {
return [
'key' => 'field_types',
'label' => 'Field types',
'weight' => 20,
];
}
/**
* {@inheritdoc}
*/
public function getDataSummary(): array {
return $this->listFieldTypesOptions();
}
/**
* Get the list of field types data.
*
* @return
* The processed field types data.
*/
public function listFieldTypes() {
return $this->loadFieldTypeData();
}
/**
* Get a list of options for field types.
*
* @return
* An array of field types as options suitable for FormAPI.
*/
public function listFieldTypesOptions() {
$field_types_data = $this->loadFieldTypeData();
$return = [];
foreach ($field_types_data as $field_type_id => $field_type_info) {
$return[$field_type_id] = $field_type_info['label'];
}
return $return;
}
/**
* Loads the field type data from storage.
*
* @return
* The data array, as stored by the FieldTypesCollector.
*/
protected function loadFieldTypeData() {
if (!isset($this->fieldTypesData)) {
$this->fieldTypesData = $this->environment->getStorage()->retrieve('field_types');
}
return $this->fieldTypesData;
}
}