This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdvf.api.php
82 lines (74 loc) · 2.11 KB
/
dvf.api.php
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
<?php
/**
* @file
* Hooks provided by the DVF module.
*
* @ingroup svf
*/
use Drupal\dvf\Plugin\VisualisationInterface;
/**
* @addtogroup hooks
* @{
*/
/**
* Alter the visualisation source configuration.
*
* @param array $configuration
* The configuration options.
* @param \Drupal\dvf\Plugin\VisualisationInterface $visualisation
* The Visualisation instance.
*/
function hook_dvf_source_configuration_alter(array &$configuration, VisualisationInterface $visualisation) {
// Change the JSON expression for entity whose id is '12345'.
if ($visualisation->getEntity()->id() == '12345') {
$configuration['json']['expression'] = '$.books[?(@.price > 10)]';
}
}
/**
* Alter the visualisation style configuration.
*
* @param array $configuration
* The configuration options.
* @param \Drupal\dvf\Plugin\VisualisationInterface $visualisation
* The Visualisation instance.
*/
function hook_dvf_style_configuration_alter(array &$configuration, VisualisationInterface $visualisation) {
// Show a title only on a 'page' bundle.
if ($visualisation->getEntity()->bundle() == 'page') {
$configuration['chart']['title']['show'] = TRUE;
}
}
/**
* Alter the visualisation render array pre render.
*
* @param array $build
* The built visualisation render array.
* @param \Drupal\dvf\Plugin\VisualisationInterface $visualisation
* The Visualisation instance.
*/
function hook_dvf_visualisation_build_alter(array &$build, VisualisationInterface $visualisation) {
// Add a custom class to all tables.
foreach ($build as $group_id => &$item) {
$item['table']['#attributes']['class'][] = 'my-table-' . $group_id;
}
}
/**
* Alter the visualisation data pre render.
*
* @param array $data
* The parsed records from the data set.
* @param \Drupal\dvf\Plugin\VisualisationInterface $visualisation
* The Visualisation instance.
*/
function hook_dvf_visualisation_data_alter(array &$data, VisualisationInterface $visualisation) {
// Count all rows.
$count = 0;
foreach ($data as $record) {
foreach ($record as $value) {
$count++;
}
}
}
/**
* @} End of "addtogroup hooks".
*/