-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy_extra.module
More file actions
118 lines (105 loc) · 3.73 KB
/
Copy pathdeploy_extra.module
File metadata and controls
118 lines (105 loc) · 3.73 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* @file
* Include core implementations.
*/
/**
* Deployment statuses.
*/
define('DEPLOY_EXTRA_IMPORT_STATUS_PROCESSED', 0);
define('DEPLOY_EXTRA_IMPORT_STATUS_SAVED', 1);
define('DEPLOY_EXTRA_IMPORT_STATUS_UPDATED', 2);
define('DEPLOY_EXTRA_IMPORT_STATUS_SKIPPED', 3);
define('DEPLOY_EXTRA_IMPORT_STATUS_TEST_MODE', 4);
define('DEPLOY_EXTRA_IMPORT_STATUS_FAILED', 5);
define('DEPLOY_EXTRA_IMPORT_DEFAULT_CALLBACK', 'deploy_extra_import_entity_save');
/**
* Include the services hook implementations.
*/
module_load_include('inc', 'deploy_extra', 'deploy_extra.core');
/**
* Include core functions provided by the Deploy Extra module.
*/
module_load_include('inc', 'deploy_extra', 'deploy_extra.services');
/**
* Implements hook_form_alter().
*/
function deploy_extra_form_alter(&$form, &$form_state, $form_id) {
if (isset($form_state['item']) && $form_id == 'ctools_export_ui_edit_item_wizard_form') {
$plugin = $form_state['plugin'];
// Make changes only for deployPlan and endPoint edit form.
if (isset($plugin['schema']) && ($plugin['schema'] == 'deploy_plans' || $plugin['schema'] == 'deploy_endpoints')) {
// Set weight property to locate our element after "debug" element.
$n = 1;
foreach ($form as $name => &$el) {
if (!strstr($name, '#') && !isset($el['#weight']) && isset($el['#weight']) && $el['#type'] != 'hidden' && $el['#type'] != 'value') {
$el['#weight'] = $n;
$n += 3;
}
}
}
}
// Alter the import form and add tmode & skip to import config.
if ($form_id == 'deploy_extra_import_entity_import_form') {
$form['import']['import_config']['tmode'] = array(
'#title' => t('Test mode'),
'#description' => t('Select this if the test mode should be enabled. All entities will not be created/updated.'),
'#type' => 'checkbox',
'#default_value' => 0,
'#weight' => -100,
);
$form['import']['import_config']['skip'] = array(
'#title' => t('Skip mode'),
'#description' => t('Select this if the skip mode should be enabled. Existing entities will be skipped.'),
'#type' => 'checkbox',
'#default_value' => 0,
'#weight' => -99,
'#states' => array(
'disabled' => array(
':input[name="tmode"]' => array(
'checked' => TRUE,
)
),
)
);
}
}
/**
* Implements hook_deploy_extra_config_form_alter().
*/
function deploy_extra_deploy_extra_config_form_alter(&$form, &$form_state, &$values) {
$values['tmod'] = $form_state['values']['tmode'];
$values['skip'] = $form_state['values']['skip'];
}
/**
* Implements hook_deploy_services().
*/
function deploy_extra_deploy_services() {
$path = drupal_get_path('module', 'deploy_extra') . '/plugins';
// Adding the new service plugin for extensibility.
return array(
'DeployServiceRestJsonAdv' => array(
'name' => 'REST JSON advanced',
'description' => 'Same as the REST JSON service + additional modes',
'handler' => array(
'class' => 'DeployServiceRestJsonAdv',
'file' => 'DeployServiceRestJsonAdv.inc',
'path' => $path,
),
),
);
}
/**
* Implements hook_module_implements_alter().
*/
function deploy_extra_module_implements_alter(&$implementations, $hook) {
if ($hook == 'services_resources_alter') {
// Move deploy_extra_services_resources_alter() to the end of the list.
// module_implements() iterates through $implementations with a foreach
// loop which PHP iterates in the order that the items were added,
// so to move an item to the end of the array, we remove it and then add it.
$group = $implementations['deploy_extra'];
unset($implementations['deploy_extra']);
$implementations['deploy_extra'] = $group;
}
}