1
|
<?php
|
2
|
|
3
|
require_once("lib/class.Diff.php");
|
4
|
require_once("classes/NameRenderConfiguration.php");
|
5
|
|
6
|
/**
|
7
|
* @file
|
8
|
* Drush integration for the devel module.
|
9
|
*/
|
10
|
|
11
|
/**
|
12
|
* Implements hook_drush_command().
|
13
|
*/
|
14
|
function cdm_dataportal_drush_command() {
|
15
|
$items['drop-cdm-nodes'] = array(
|
16
|
'description' => dt('Drops all drupal nodes created for cdm content.'),
|
17
|
);
|
18
|
$items['cdm-render-templates-config-status'] = array(
|
19
|
'description' => dt('Reports the status of the drupal variable ' . NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES . ', whether DEFAULT, CUSTOM, or PRE_380'),
|
20
|
'aliases' => ['cdm-rtcs'],
|
21
|
);
|
22
|
$items['cdm-name-part-config-status'] = array(
|
23
|
'description' => dt('Reports the status of the drupal variable ' . NameRenderConfiguration::CDM_PART_DEFINITIONS . ', whether DEFAULT, CUSTOM, or PRE_380'),
|
24
|
'aliases' => ['cdm-npcs'],
|
25
|
);
|
26
|
$items['cdm-render-templates-config-diff'] = array(
|
27
|
'description' => dt('Provides the diff of the default and the actual value of the drupal variable ' . NameRenderConfiguration::CDM_NAME_RENDER_TEMPLATES),
|
28
|
'aliases' => ['cdm-rtcd'],
|
29
|
);
|
30
|
$items['cdm-name-part-config-diff'] = array(
|
31
|
'description' => dt('Provides the diff of the default and the actual value of the drupal variable ' . NameRenderConfiguration::CDM_PART_DEFINITIONS),
|
32
|
'aliases' => ['cdm-npcd'],
|
33
|
);
|
34
|
return $items;
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* Callback for the drop-cdm-nodes command
|
39
|
*/
|
40
|
function drush_cdm_dataportal_drop_cdm_nodes(){
|
41
|
cdm_delete_all_cdm_nodes();
|
42
|
drush_print("All cdm related drupal nodes dropped");
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* Callback for the 'cdm-render-templates-config-status' command
|
47
|
*/
|
48
|
function drush_cdm_dataportal_cdm_render_templates_config_status(){
|
49
|
$nameRenderConfiguration = new NameRenderConfiguration();
|
50
|
$config_status = $nameRenderConfiguration->nameRenderTemplateConfigurationStatus();
|
51
|
$status_label = status_label($config_status);
|
52
|
drush_print($status_label);
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* Callback for the 'cdm-name-part-config-status' command
|
57
|
*/
|
58
|
function drush_cdm_dataportal_cdm_name_part_config_status(){
|
59
|
$nameRenderConfiguration = new NameRenderConfiguration();
|
60
|
$config_status = $nameRenderConfiguration->partDefinitionConfigurationStatus();
|
61
|
$status_label = status_label($config_status);
|
62
|
drush_print($status_label);
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* Callback for the 'cdm-render-templates-config-diff' command
|
67
|
*/
|
68
|
function drush_cdm_dataportal_cdm_render_templates_config_diff(){
|
69
|
$nameRenderConfiguration = new NameRenderConfiguration();
|
70
|
$config_status = $nameRenderConfiguration->nameRenderTemplateConfigurationStatus();
|
71
|
if($config_status == NameRenderConfiguration::CUSTOM_CONFIGURATION){
|
72
|
$diff = Diff::compare($nameRenderConfiguration->getDefaultRenderTemplatesJson(), $nameRenderConfiguration->getCurrentRenderTemplatesJson());
|
73
|
drush_print(Diff::toString($diff));
|
74
|
}
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* Callback for the 'cdm-render-templates-config-diff' command
|
79
|
*/
|
80
|
function drush_cdm_dataportal_cdm_name_part_config_diff(){
|
81
|
$nameRenderConfiguration = new NameRenderConfiguration();
|
82
|
$config_status = $nameRenderConfiguration->partDefinitionConfigurationStatus();
|
83
|
if($config_status == NameRenderConfiguration::CUSTOM_CONFIGURATION){
|
84
|
$diff = Diff::compare($nameRenderConfiguration->getDefaultPartDefinitionJson(), $nameRenderConfiguration->getCurrentPartDefinitionJson());
|
85
|
drush_print(Diff::toString($diff));
|
86
|
}
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* @param $config_status
|
91
|
*
|
92
|
* @return string
|
93
|
*/
|
94
|
function status_label($config_status) {
|
95
|
$status_label = '';
|
96
|
switch ($config_status) {
|
97
|
case NameRenderConfiguration::PRE380_CONFIGURATION:
|
98
|
$status_label = 'PRE_380';
|
99
|
break;
|
100
|
case NameRenderConfiguration::CUSTOM_CONFIGURATION:
|
101
|
$status_label = 'CUSTOM';
|
102
|
break;
|
103
|
case NameRenderConfiguration::DEFAULT_CONFIGURATION:
|
104
|
default:
|
105
|
$status_label = 'DEFAULT';
|
106
|
}
|
107
|
return $status_label;
|
108
|
}
|