Skip to content

Commit

Permalink
Apply coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Apr 17, 2023
1 parent 4d69362 commit e3023ae
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 45 deletions.
5 changes: 4 additions & 1 deletion modules/os2forms_webform_maps/os2forms_webform_maps.module
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use Drupal\Component\Render\FormattableMarkup;
/**
* @file
* Module file for os2forms_webform_maps.
*/

/**
* Implements hook_theme().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
namespace Drupal\os2forms_webform_maps\Element;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\FormElement;
use Drupal\Core\Render\Element\Textarea;
use Drupal\leaflet\LeafletService;
use Drupal\webform\Element\WebformCompositeFormElementTrait;
use Drupal\webform\Utility\WebformElementHelper;

/**
* Provides a webform_map_field.
Expand Down Expand Up @@ -118,7 +114,7 @@ public static function processWebformMapElement(&$element, FormStateInterface $f
];
$map['context'] = 'widget';

/** @var LeafletService $leaflet_service */
/** @var \Drupal\leaflet\LeafletService $leaflet_service */
$leaflet_service = \Drupal::service('leaflet.service');
$element['map'] = $leaflet_service->leafletRenderMap($map, $feature, $element['#mapHeight'] . 'px');

Expand Down Expand Up @@ -172,7 +168,6 @@ public static function processWebformMapElement(&$element, FormStateInterface $f
];
$element['image_data']['#attributes']['class'][] = 'leaflet-widget-image';


// Initialize the mail elements to allow for webform enhancements.
/** @var \Drupal\webform\Plugin\WebformElementManagerInterface $element_manager */
$element_manager = \Drupal::service('plugin.manager.webform.element');
Expand All @@ -195,7 +190,6 @@ public static function processWebformMapElement(&$element, FormStateInterface $f
$element['#help_display']
);


// Add validate callback.
$element += ['#element_validate' => []];
array_unshift($element['#element_validate'], [
Expand Down Expand Up @@ -236,7 +230,6 @@ public static function validateWebformMapElement(&$element, FormStateInterface $
'image' => $image_data,
]) : $mail_2;


// Field must be converted from a two-element array into a single
// string regardless of validation results.
$form_state->setValueForElement($mail_element['mail_2'], NULL);
Expand All @@ -245,4 +238,5 @@ public static function validateWebformMapElement(&$element, FormStateInterface $
$element['#value'] = $result;
$form_state->setValueForElement($element, $result);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\leaflet\LeafletSettingsElementsTrait;
use Drupal\webform\Plugin\WebformElementBase;
use Drupal\webform\WebformSubmissionInterface;

/**
* Provides a 'webform_map_field' element.
Expand All @@ -16,9 +15,7 @@
* description = @Translation("Provides a webform map field."),
* category = @Translation("OS2Forms"),
* )
*
*/

class WebformLeafletMapField extends WebformElementBase {

use LeafletSettingsElementsTrait;
Expand All @@ -28,44 +25,44 @@ class WebformLeafletMapField extends WebformElementBase {
*/
public function defineDefaultProperties(): array {
return [
'mapHeight' => 600,
'map_layers' => '',
'lat' => 0,
'lon' => 0,
'zoom' => 12,
'minZoom' => 1,
'maxZoom' => 18,
'zoomFiner' => 0,
'scrollWheelZoom' => 0,
'doubleClickZoom' => 1,
'mapHeight' => 600,
'map_layers' => '',
'lat' => 0,
'lon' => 0,
'zoom' => 12,
'minZoom' => 1,
'maxZoom' => 18,
'zoomFiner' => 0,
'scrollWheelZoom' => 0,
'doubleClickZoom' => 1,

'position' => 'topleft',
'marker' => 'defaultMarker',
'drawPolyline' => 0,
'drawRectangle' => 0,
'drawPolygon' => 0,
'drawCircle' => 0,
'drawText' => 0,
'editMode' => 0,
'dragMode' => 0,
'cutPolygon' => 0,
'removalMode' => 0,
'rotateMode' => 0,
'position' => 'topleft',
'marker' => 'defaultMarker',
'drawPolyline' => 0,
'drawRectangle' => 0,
'drawPolygon' => 0,
'drawCircle' => 0,
'drawText' => 0,
'editMode' => 0,
'dragMode' => 0,
'cutPolygon' => 0,
'removalMode' => 0,
'rotateMode' => 0,

'polyline_color' => '#3388FF',
'polyline_intersection' => 0,
'polyline_error_color' => '#3388FF',
'polyline_error_message' => '',
'polyline_color' => '#3388FF',
'polyline_intersection' => 0,
'polyline_error_color' => '#3388FF',
'polyline_error_message' => '',

'polygon_color' => '#3388FF',
'polygon_intersection' => 0,
'polygon_error_color' => '#3388FF',
'polygon_error_message' => '',
'polygon_color' => '#3388FF',
'polygon_intersection' => 0,
'polygon_error_color' => '#3388FF',
'polygon_error_message' => '',

'circle_color' => '#3388FF',
'rectangle_color' => '#3388FF',
'circle_color' => '#3388FF',
'rectangle_color' => '#3388FF',

] + parent::defineDefaultProperties();
] + parent::defineDefaultProperties();
}

/**
Expand Down Expand Up @@ -334,4 +331,5 @@ public function form(array $form, FormStateInterface $form_state) {

return $form;
}

}
2 changes: 2 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<exclude-pattern>vendor/</exclude-pattern>
<!-- Exclude our copy of the abandoned https://www.drupal.org/project/webform_embed -->
<exclude-pattern>modules/webform_embed/</exclude-pattern>
<!-- Exclude our copy of the abandoned https://www.drupal.org/project/field_color -->
<exclude-pattern>modules/os2forms_webform_maps/modules/field_color/</exclude-pattern>

<!-- Show progress of the run -->
<arg value="p"/>
Expand Down

0 comments on commit e3023ae

Please sign in to comment.