Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 132d14d

Browse files
committed
OS2FORMS-380 Fixed coding standards issues
1 parent bc9e28f commit 132d14d

File tree

9 files changed

+177
-146
lines changed

9 files changed

+177
-146
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ before starting to add changes.
1111

1212
### Added
1313
- Github CI action for checking Drupal Coding standards with PHP Code Sniffer
14+
- Fixed coding standards issues
1415

1516

1617
## Example of change log record

css/gin-custom.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.ui-dialog:not(.ui-dialog-off-canvas) {
2-
width: 70vw!important;
2+
width: 70vw!important;
33
}

os2forms_forloeb.info.yml

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,51 @@ core: 8.x
66
core_version_requirement: ^8 || ^9
77

88
dependencies:
9-
- admin_toolbar_tools
10-
- coc_forms_auto_export
11-
- config_entity_revisions
12-
- diff
13-
- entity_print
14-
- eu_cookie_compliance
15-
- events_logging
16-
- gin_toolbar
17-
- honeypot
18-
- libraries
19-
- maestro
20-
- mailsystem
21-
- masquerade
22-
- os2forms
23-
- os2forms_nemid
24-
- os2forms_dawa
25-
- os2forms_sbsys
26-
- os2web_simplesaml
27-
- pathauto
28-
- r4032login
29-
- redirect
30-
- smtp
31-
- system
32-
- switch_page_theme
33-
- token
34-
- ultimate_cron
35-
- user_default_page
36-
- webform
37-
- webform_ui
38-
- webform_access
39-
- webform_attachment
40-
- webform_composite
41-
- webform_embed
42-
- webform_entity_print
43-
- webform_entity_print_attachment
44-
- webform_migrate
45-
- webform_node_element
46-
- webform_remote_handlers
47-
- webform_rest
48-
- webform_revisions
49-
- webform_share
50-
- webform_scheduled_email
51-
- webform_submission_export_import
52-
- webform_submission_log
53-
- webform_templates
54-
- workflow_participants
9+
- 'drupal:admin_toolbar_tools'
10+
- 'drupal:coc_forms_auto_export'
11+
- 'drupal:config_entity_revisions'
12+
- 'drupal:diff'
13+
- 'drupal:entity_print'
14+
- 'drupal:eu_cookie_compliance'
15+
- 'drupal:events_logging'
16+
- 'drupal:gin_toolbar'
17+
- 'drupal:honeypot'
18+
- 'drupal:libraries'
19+
- 'drupal:maestro'
20+
- 'drupal:mailsystem'
21+
- 'drupal:masquerade'
22+
- 'drupal:os2forms'
23+
- 'drupal:os2forms_nemid'
24+
- 'drupal:os2forms_dawa'
25+
- 'drupal:os2forms_sbsys'
26+
- 'drupal:os2web_simplesaml'
27+
- 'drupal:pathauto'
28+
- 'drupal:r4032login'
29+
- 'drupal:redirect'
30+
- 'drupal:smtp'
31+
- 'drupal:system'
32+
- 'drupal:switch_page_theme'
33+
- 'drupal:token'
34+
- 'drupal:ultimate_cron'
35+
- 'drupal:user_default_page'
36+
- 'drupal:webform'
37+
- 'drupal:webform_ui'
38+
- 'drupal:webform_access'
39+
- 'drupal:webform_attachment'
40+
- 'drupal:webform_composite'
41+
- 'drupal:webform_embed'
42+
- 'drupal:webform_entity_print'
43+
- 'drupal:webform_entity_print_attachment'
44+
- 'drupal:webform_migrate'
45+
- 'drupal:webform_node_element'
46+
- 'drupal:webform_remote_handlers'
47+
- 'drupal:webform_rest'
48+
- 'drupal:webform_revisions'
49+
- 'drupal:webform_share'
50+
- 'drupal:webform_scheduled_email'
51+
- 'drupal:webform_submission_export_import'
52+
- 'drupal:webform_submission_log'
53+
- 'drupal:webform_templates'
54+
- 'drupal:workflow_participants'
5555
'interface translation project': os2forms_forloeb
5656
'interface translation server pattern': modules/contrib/os2forms_forloeb/translations/os2forms_forloeb.da.po

os2forms_forloeb.module

Lines changed: 68 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<?php
22

3+
/**
4+
* @file
5+
* Install, update and uninstall functions for the os2forms_forloeb.
6+
*/
7+
8+
use Drupal\Core\Session\AccountInterface;
9+
use Drupal\Core\Entity\EntityInterface;
310
use Drupal\webform\WebformInterface;
411
use Drupal\Core\Access\AccessResult;
512
use Drupal\Core\Form\FormStateInterface;
@@ -10,12 +17,9 @@ use Drupal\webform\Entity\WebformSubmission;
1017
use Drupal\user\Entity\User;
1118

1219
/**
13-
* @file
14-
* Install, update and uninstall functions for the os2forms_forloeb_profile installation profile.
15-
*/
16-
17-
/**
18-
* Implements hook_maestro_interactive_handlers() for the return of an Array
20+
* Implements hook_maestro_interactive_handlers().
21+
*
22+
* Handler for the return of an Array
1923
* of function names and help text that will be displayed in the edit task
2024
* form under the handler field.
2125
*/
@@ -35,70 +39,75 @@ function os2forms_forloeb_maestro_interactive_handlers() {
3539
* @param int $queueID
3640
* The queueID from Maestro.
3741
*/
38-
function os2forms_forloeb_workflow_maestro_reassign_form(&$form, $obj, $queueID = 0) {
42+
function os2forms_forloeb_workflow_maestro_reassign_form(array &$form, $obj, $queueID = 0) {
3943

40-
$form['reviewer'] = array(
44+
$form['reviewer'] = [
4145
'#id' => 'select_assigned_user',
4246
'#type' => 'entity_autocomplete',
4347
'#target_type' => 'user',
4448
'#default_value' => '',
4549
'#selection_settings' => ['include_anonymous' => FALSE],
46-
'#title' => t('Assign for Review to'),
47-
);
50+
'#title' => t('Assign for Review to'),
51+
];
4852

49-
$form['queueID'] = array(
53+
$form['queueID'] = [
5054
'#type' => 'hidden',
5155
'#title' => 'the queue ID in the event we need it in later processing',
5256
'#default_value' => $queueID,
5357
'#description' => ('queueID'),
54-
);
58+
];
5559

56-
//overriding the default label "complete"
60+
// Overriding the default label "complete".
5761
$form['actions']['submit']['#value'] = t('Assign');
5862

5963
return $form;
6064
}
6165

62-
6366
/**
64-
* This is the submit handler for the Reassign for Approval form use in maestro workflows.
67+
* Submit handler for The Reassign for Approval form.
68+
*
69+
* This is the submit handler for the Reassign for Approval form
70+
* used in maestro workflows.
6571
*/
6672
function os2forms_forloeb_workflow_maestro_reassign_form_submit(&$form, &$form_state) {
6773

6874
$queueID = intval($form_state->getValue('queueID'));
6975
$processID = MaestroEngine::getProcessIdFromQueueId($queueID);
7076

71-
//Who was selected? Load their username, which is the user attribute that Maestro assigns tasks by.
77+
// Who was selected? Load their username, which is the user attribute
78+
// that Maestro assigns tasks by.
7279
$reviewer_uid = $form_state->getValue('reviewer');
73-
$reviewer = User::load($reviewer_uid); // pass your uid
80+
// Pass your uid.
81+
$reviewer = User::load($reviewer_uid);
7482
$reviewer_username = $reviewer->getAccountName();
7583

76-
//add that user to our maestro process variable.
84+
// Add that user to our maestro process variable.
7785
MaestroEngine::setProcessVariable("assigned_to", $reviewer_username, $processID);
7886

79-
//Provide some feedback
87+
// Provide some feedback.
8088
\Drupal::messenger()->addStatus("Content Reassigned");
81-
8289
}
8390

8491
/**
85-
* * Implements hook_maestro_batch_handlers().
86-
* *
87-
* * Array of function names and help text that will be displayed
88-
* * in the edit task form under the handler field.
89-
* */
92+
* Implements hook_maestro_batch_handlers().
93+
*
94+
* Array of function names and help text that will be displayed
95+
* in the edit task form under the handler field.
96+
*/
9097
function os2forms_forloeb_maestro_batch_handlers() {
9198
return [
9299
'end_notification_batch_function' => t('Batch function to send out flow completion notification to initiator.'),
93100
];
94101
}
95102

96103
/**
97-
* * @param int $processID
98-
* * The Maestro process ID.
99-
* * @param int $queueID
100-
* * The Maestro queue ID.
101-
* */
104+
* Finishing callback for batch handler.
105+
*
106+
* @param int $processID
107+
* The Maestro process ID.
108+
* @param int $queueID
109+
* The Maestro queue ID.
110+
*/
102111
function end_notification_batch_function($processID, $queueID) {
103112

104113
/*
@@ -116,7 +125,7 @@ function end_notification_batch_function($processID, $queueID) {
116125

117126
if ($sid) {
118127
$webform_submission = WebformSubmission::load($sid);
119-
$webform = $webform_submission->getWebform();
128+
$webform = $webform_submission->getWebform();
120129
$handlers = $webform->getHandlers();
121130

122131
foreach ($handlers as $handler) {
@@ -131,27 +140,29 @@ function end_notification_batch_function($processID, $queueID) {
131140
}
132141

133142
/**
134-
* Implements hook_ENTITY_TYPE_create()
143+
* Implements hook_ENTITY_TYPE_create().
144+
*
135145
* Sets a global purge setting for all webform submissions to 30 days.
136146
*/
137147
function os2forms_forloeb_webform_create(WebformInterface $webform) {
138-
// Set purge of all users submissions.
139-
$webform->setSetting('purge', 'all');
140-
// Set purge of submissions more than 30 days old.
141-
if (empty($webform->getSetting('purge_days'))) {
142-
$webform->setSetting('purge_days', '30');
143-
}
148+
// Set purge of all users submissions.
149+
$webform->setSetting('purge', 'all');
150+
// Set purge of submissions more than 30 days old.
151+
if (empty($webform->getSetting('purge_days'))) {
152+
$webform->setSetting('purge_days', '30');
153+
}
144154
}
145155

146156
/**
147-
* Implements hook_ENTITY_TYPE_presave()
157+
* Implements hook_ENTITY_TYPE_presave().
158+
*
148159
* Update webform specific submissions purge settings.
149160
*/
150161
function os2forms_forloeb_webform_presave(WebformInterface $webform) {
151-
// Add a purge time frame if not set.
152-
if (empty($webform->getSetting('purge_days'))) {
153-
$webform->setSetting('purge_days', 30);
154-
}
162+
// Add a purge time frame if not set.
163+
if (empty($webform->getSetting('purge_days'))) {
164+
$webform->setSetting('purge_days', 30);
165+
}
155166
}
156167

157168
/**
@@ -203,8 +214,7 @@ function os2forms_forloeb_spv_fetch_entity_username($uniqueWebformIdentifier, $w
203214
}
204215

205216
/**
206-
* Returns array of custom task-types for OS2forms
207-
*
217+
* Returns array of custom task-types for OS2forms.
208218
*/
209219
function os2forms_forloeb_get_custom_task_types() {
210220
return ['MaestroWebformMultiple', 'MaestroWebformInherit'];
@@ -216,28 +226,29 @@ function os2forms_forloeb_get_custom_task_types() {
216226
* This has been copied from
217227
* maestro/maestro_webform/maestro_webform.module with a minimal but
218228
* necessary change. See https://www.drupal.org/project/maestro/issues/3243510
219-
* When that issue has been fixed, this hook implementation can be safely deleted.
220-
*
229+
* When that issue has been fixed, this hook implementation
230+
* can be safely deleted.
221231
*/
222232
function os2forms_forloeb_form_alter(&$form, FormStateInterface $form_state, $form_id) {
223233
$queueID = intval(\Drupal::request()->query->get('queueid', 0));
224234
$isMaestro = intval(\Drupal::request()->query->get('maestro', 0));
225235
// Both these keys need to exist.
226236
if ($isMaestro && $queueID) {
227237
$templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID);
228-
// Get array of custom task-types
238+
// Get array of custom task-types.
229239
$os2forms_forloeb_custom_task_types = os2forms_forloeb_get_custom_task_types();
230-
// We only care about custom Task-types defined in os2forms_forloeb_get_custom_task_types()
240+
// We only care about custom Task-types
241+
// defined in os2forms_forloeb_get_custom_task_types()
231242
if ($templateTask && in_array($templateTask['tasktype'], $os2forms_forloeb_custom_task_types)) {
232243
$storage = $form_state->getStorage();
233244
if ($storage && array_key_exists('form_display', $storage)) {
234-
$webformTypes = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();
235245
$thisForm = $storage['form_display']->get('bundle');
236246
$targetEntityType = $storage['form_display']->get('targetEntityType');
237247
if ($isMaestro == 1 &&
238248
$targetEntityType == 'webform_submission' &&
239249
$templateTask['data']['webform_machine_name'] == $thisForm) {
240-
// We now know this is a webform submission. We are going to add in our own form fields here.
250+
// We now know this is a webform submission.
251+
// We are going to add in our own form fields here.
241252
$form['maestro'] = [
242253
'#tree' => TRUE,
243254
];
@@ -268,8 +279,11 @@ function os2forms_forloeb_form_alter(&$form, FormStateInterface $form_state, $fo
268279
}
269280
}
270281

282+
/**
283+
* Implements hook_preprocess_page().
284+
*/
271285
function os2forms_forloeb_preprocess_page(&$variables) {
272-
$variables['#attached']['library'][] = 'os2forms_forloeb/os2forms_forloeb';
286+
$variables['#attached']['library'][] = 'os2forms_forloeb/os2forms_forloeb';
273287
}
274288

275289
/**
@@ -304,9 +318,10 @@ function os2forms_forloeb_tokens($type, array $tokens, array $data, array $optio
304318

305319
/**
306320
* Implements hook_entity_access().
321+
*
307322
* Allows requests with tokens to view the entity.
308323
*/
309-
function os2forms_forloeb_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
324+
function os2forms_forloeb_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
310325
if ($operation == 'update' && $entity instanceof WebformSubmission) {
311326
$token = \Drupal::request()->query->get('os2forms-forloeb-ws-token');
312327
if ($token && $token === $entity->getToken()) {

0 commit comments

Comments
 (0)