-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DW-578: Added os2forms_selvbetjening module altering email handler form
- Loading branch information
Showing
7 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
web/modules/custom/os2forms_selvbetjening/os2forms_selvbetjening.info.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: 'OS2Forms Selvbetjening' | ||
type: module | ||
description: 'Provides changes to webform email handler.' | ||
package: 'OS2Forms' | ||
core: 8.x | ||
core_version_requirement: ^8 || ^9 | ||
dependencies: | ||
- 'webform:webform' |
18 changes: 18 additions & 0 deletions
18
web/modules/custom/os2forms_selvbetjening/os2forms_selvbetjening.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Module file for the os2forms_selvbetjening module. | ||
*/ | ||
|
||
use Drupal\Core\Form\FormStateInterface; | ||
use Drupal\os2forms_selvbetjening\Helper\FormHelper; | ||
|
||
/** | ||
* Implements hook_form_alter(). | ||
* | ||
* Allows altering of forms. | ||
*/ | ||
function os2forms_selvbetjening_form_alter(&$form, FormStateInterface $form_state, $form_id) { | ||
Drupal::service(FormHelper::class)->formAlter($form, $form_state, $form_id); | ||
} |
4 changes: 4 additions & 0 deletions
4
web/modules/custom/os2forms_selvbetjening/os2forms_selvbetjening.services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
services: | ||
Drupal\os2forms_selvbetjening\Helper\FormHelper: | ||
arguments: | ||
- '@config.factory' |
43 changes: 43 additions & 0 deletions
43
web/modules/custom/os2forms_selvbetjening/src/Helper/FormHelper.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Drupal\os2forms_selvbetjening\Helper; | ||
|
||
use Drupal\Core\Config\ConfigFactoryInterface; | ||
use Drupal\Core\Form\FormStateInterface; | ||
|
||
/** | ||
* Form Helper class, for altering forms. | ||
*/ | ||
class FormHelper { | ||
|
||
/** | ||
* The ConfigFactoryInterface. | ||
* | ||
* @var \Drupal\Core\Config\ConfigFactoryInterface | ||
*/ | ||
private ConfigFactoryInterface $config; | ||
|
||
/** | ||
* Constructs a FormHelper. | ||
*/ | ||
public function __construct(ConfigFactoryInterface $config) { | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* Allows altering of forms. | ||
*/ | ||
public function formAlter(&$form, FormStateInterface $form_state, $form_id) { | ||
|
||
// Add description to the message body section of the email handler. | ||
if ('webform_handler_form' === $form_id && 'email' === ($form['#webform_handler_plugin_id'] ?? NULL)) { | ||
|
||
$config = $this->config->get('os2forms_selvbetjening'); | ||
|
||
if ($email_body_description = $config->get('email_body_description')) { | ||
$form['settings']['message']['body']['#description'] = $email_body_description; | ||
} | ||
} | ||
} | ||
|
||
} |