Skip to content

Commit 9092a56

Browse files
Merge pull request #101 from localgovdrupal/1.x
Release 1.0.0-beta9
2 parents 43d1e6a + e3b4c66 commit 9092a56

36 files changed

+347
-58
lines changed

localgov_forms.install

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
*/
77

88
use Drupal\Component\Serialization\Yaml;
9+
use Drupal\Core\StringTranslation\TranslatableMarkup;
910
use Drupal\webform\Entity\WebformOptions;
1011

1112
/**
1213
* Implements hook_install().
1314
*/
14-
function localgov_forms_install() {
15+
function localgov_forms_install(): void {
1516

1617
// Override Webforms default configuration.
1718
$config = \Drupal::configFactory()->getEditable('localgov_forms.webform.settings');
@@ -24,7 +25,7 @@ function localgov_forms_install() {
2425
*
2526
* Creates a Webform option for Local custodian codes.
2627
*/
27-
function localgov_forms_update_8001() {
28+
function localgov_forms_update_8001(): ?TranslatableMarkup {
2829

2930
$has_local_custodian_codes_option = Drupal::service('entity_type.manager')->getStorage('webform_options')->load('local_custodian_codes_gb');
3031
if ($has_local_custodian_codes_option) {
@@ -39,4 +40,6 @@ function localgov_forms_update_8001() {
3940
$local_custodian_codes_option = Yaml::decode(file_get_contents(__DIR__ . '/config/install/webform.webform_options.local_custodian_codes_gb.yml'));
4041
$new_local_custodian_codes_option = WebformOptions::create($local_custodian_codes_option);
4142
$new_local_custodian_codes_option->save();
43+
44+
return NULL;
4245
}

localgov_forms.module

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Drupal\Core\Render\Element;
1010
/**
1111
* Implements hook_theme().
1212
*/
13-
function localgov_forms_theme() {
13+
function localgov_forms_theme(): array {
1414
return [
1515
// Form element: localgov_webform_uk_address.
1616
'localgov_forms_uk_address_lookup' => [
@@ -29,7 +29,7 @@ function localgov_forms_theme() {
2929
* Makes sub-elements available within the `content` variable. Mostly lifted
3030
* from _template_preprocess_webform_composite().
3131
*/
32-
function template_preprocess_localgov_forms_uk_address_lookup(array &$variables) {
32+
function template_preprocess_localgov_forms_uk_address_lookup(array &$variables): void {
3333

3434
$element = $variables['element'];
3535
foreach (Element::children($element) as $key) {
@@ -44,14 +44,14 @@ function template_preprocess_localgov_forms_uk_address_lookup(array &$variables)
4444
/**
4545
* Prepares variables for the UK address element template.
4646
*/
47-
function template_preprocess_localgov_forms_uk_address(array &$variables) {
47+
function template_preprocess_localgov_forms_uk_address(array &$variables): void {
4848

4949
template_preprocess_localgov_forms_uk_address_lookup($variables);
5050
}
5151

5252
/**
5353
* Implements hook_preprocess_hook() for hook_preprocess_webform().
5454
*/
55-
function localgov_forms_preprocess_webform(array &$variables) {
55+
function localgov_forms_preprocess_webform(array &$variables): void {
5656
$variables['#attached']['library'][] = 'localgov_forms/localgov_forms.form_errors';
5757
}

localgov_forms.tokens.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Drupal\webform\Utility\WebformDateHelper;
1616
*
1717
* Token declarations.
1818
*/
19-
function localgov_forms_token_info() {
19+
function localgov_forms_token_info(): array {
2020

2121
return [
2222
'tokens' => [
@@ -42,7 +42,7 @@ function localgov_forms_token_info() {
4242
*
4343
* @see system_tokens()
4444
*/
45-
function localgov_forms_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
45+
function localgov_forms_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata): array {
4646

4747
$replacements = [];
4848

modules/localgov_forms_date/css/date.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
}
55

66
.localgov-forms-date div[class*="-day"] {
7-
margin-left: 0em;
87
flex: 1;
98
max-width: 100%;
109
margin-top: 0.5em;
1110
margin-right: 0.5em;
11+
margin-left: 0;
1212
}
1313

1414
.localgov-forms-date div[class*="-month"] {
1515
flex: 2;
16-
margin: 0.5em;
1716
max-width: 100%;
17+
margin: 0.5em;
1818
}
1919

2020
.localgov-forms-date div[class*="-year"] {

modules/localgov_forms_date/localgov_forms_date.install

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use Drupal\Component\Serialization\Yaml;
1010
/**
1111
* Adds a UK short date style e.g dd-mm-yyyy.
1212
*/
13-
function localgov_forms_date_update_8001() {
13+
function localgov_forms_date_update_8001(): void {
1414
$config_id = 'core.date_format.localgov_forms_date_short_date';
1515
$config_path = \Drupal::service('extension.list.module')->getPath('localgov_forms_date');
1616
$uk_short_html_date_config = Yaml::decode(file_get_contents($config_path . '/config/install/' . $config_id . '.yml'));
@@ -20,7 +20,7 @@ function localgov_forms_date_update_8001() {
2020
/**
2121
* Adds a UK short date style e.g dd-mm-yyyy HH:mm:ss.
2222
*/
23-
function localgov_forms_date_update_8002() {
23+
function localgov_forms_date_update_8002(): void {
2424
$config_id = 'core.date_format.localgov_forms_date_datetime';
2525
$config_path = \Drupal::service('extension.list.module')->getPath('localgov_forms_date');
2626
$uk_html_datetime_config = Yaml::decode(file_get_contents($config_path . '/config/install/' . $config_id . '.yml'));
@@ -30,7 +30,7 @@ function localgov_forms_date_update_8002() {
3030
/**
3131
* Adds a UUID to LocalGov Forms Date formats.
3232
*/
33-
function localgov_forms_date_update_8003() {
33+
function localgov_forms_date_update_8003(): void {
3434
$localgov_date_formats = [
3535
'core.date_format.localgov_forms_date_short_date',
3636
'core.date_format.localgov_forms_date_datetime',

modules/localgov_forms_date/localgov_forms_date.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Datetime Form preprocess function.
1010
*/
11-
function localgov_forms_date_preprocess_datetime_form(array &$variables) {
11+
function localgov_forms_date_preprocess_datetime_form(array &$variables): void {
1212
// Check that this is a localgov_forms_date form element.
1313
if ($variables['element']['#type'] === 'localgov_forms_date') {
1414
$variables['attributes']['class'][] = 'localgov-forms-date';

modules/localgov_forms_date/src/Element/LocalgovFormsDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private static function restoreUnprocessedDate(array &$element) :void {
132132
* be set in the UI which should take precedence over
133133
* the default error message.
134134
*/
135-
public static function validateDatelist(&$element, FormStateInterface $form_state, &$complete_form) {
135+
public static function validateDatelist(&$element, FormStateInterface $form_state, &$complete_form): void {
136136
$input_exists = FALSE;
137137
$input = NestedArray::getValue($form_state->getValues(), $element['#parents'], $input_exists);
138138

modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function form(array $form, FormStateInterface $form_state) {
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
68+
public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void {
6969
parent::validateConfigurationForm($form, $form_state);
7070
$values = $form_state->getValues();
7171
$values['date_part_order'] = ['day', 'month', 'year'];
@@ -77,7 +77,7 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form
7777
/**
7878
* After build handler for Datelist element.
7979
*/
80-
public static function afterBuild(array $element, FormStateInterface $form_state) {
80+
public static function afterBuild(array $element, FormStateInterface $form_state): array {
8181
$element = parent::afterBuild($element, $form_state);
8282

8383
// Set the property of the date of birth elements.
@@ -112,7 +112,7 @@ public static function afterBuild(array $element, FormStateInterface $form_state
112112
*
113113
* @see Drupal\Webform\Plugin\WebformElement\DateBase::setDefaultValue()
114114
*/
115-
public function setDefaultValue(array &$element) {
115+
public function setDefaultValue(array &$element): void {
116116

117117
$orig_type = $element['#type'];
118118
$element['#type'] = 'datelist';
@@ -127,7 +127,7 @@ public function setDefaultValue(array &$element) {
127127
* date validation error messages display in
128128
* a UK Style format e.g dd-mm-yyyy.
129129
*/
130-
public static function validateDate(&$element, FormStateInterface $form_state, &$complete_form) {
130+
public static function validateDate(&$element, FormStateInterface $form_state, &$complete_form): void {
131131

132132
// Adds a short date and short date time format.
133133
$localgov_forms_short_date_format = DateFormat::load('localgov_forms_date_short_date')->getPattern();

modules/localgov_forms_date/tests/modules/localgov_forms_date_test/localgov_forms_date_test.info.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ package: Testing
55
core_version_requirement: ^8.8 || ^9 || ^10
66

77
dependencies:
8-
- webform:webform
9-
- localgov_forms:localgov_forms_date
8+
- webform:webform
9+
- localgov_forms:localgov_forms_date

modules/localgov_forms_date/tests/src/Kernel/DateWebformElementTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DateWebformElementTest extends KernelTestBase {
1717
/**
1818
* Tests a webform with our date field.
1919
*/
20-
public function testFormSubmission() {
20+
public function testFormSubmission(): void {
2121

2222
$this->passCase();
2323
$this->failCaseWithInvalidDay();
@@ -28,7 +28,7 @@ public function testFormSubmission() {
2828
/**
2929
* Tests valid date.
3030
*/
31-
protected function passCase() {
31+
protected function passCase(): void {
3232

3333
$form_state = new FormState();
3434
$form_state->setValue('date',
@@ -42,7 +42,7 @@ protected function passCase() {
4242
/**
4343
* Tests date with invalid day.
4444
*/
45-
protected function failCaseWithInvalidDay() {
45+
protected function failCaseWithInvalidDay(): void {
4646

4747
$form_state = new FormState();
4848
$form_state->setValue('date', ['day' => '1D']);
@@ -55,7 +55,7 @@ protected function failCaseWithInvalidDay() {
5555
/**
5656
* Tests date with nonnumeric day.
5757
*/
58-
protected function failCaseWithNonNumericDay() {
58+
protected function failCaseWithNonNumericDay(): void {
5959

6060
$form_state = new FormState();
6161
$form_state->setValue('date',
@@ -69,7 +69,7 @@ protected function failCaseWithNonNumericDay() {
6969
/**
7070
* Tests date with invalid year.
7171
*/
72-
protected function failCaseWithInvalidYear() {
72+
protected function failCaseWithInvalidYear(): void {
7373

7474
$form_state = new FormState();
7575
$form_state->setValue('date',
@@ -83,7 +83,7 @@ protected function failCaseWithInvalidYear() {
8383
/**
8484
* {@inheritdoc}
8585
*/
86-
protected function setUp() :void {
86+
protected function setUp(): void {
8787

8888
parent::setUp();
8989

0 commit comments

Comments
 (0)