Skip to content
Snippets Groups Projects
Commit 251930a6 authored by jrockowitz's avatar jrockowitz
Browse files

Minor improvements

parent dc0322da
No related branches found
No related tags found
No related merge requests found
<?php <?php
declare(strict_types = 1);
namespace Drupal\Tests\webform_setting_javascript\FunctionalJavascript; namespace Drupal\Tests\webform_setting_javascript\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
......
...@@ -8,17 +8,31 @@ ...@@ -8,17 +8,31 @@
/** /**
* Implements hook_install(). * Implements hook_install().
*/ */
function webform_javascript_setting_install() { function webform_javascript_setting_install(bool $is_syncing): void {
if ($is_syncing) {
return;
}
$settings = [];
// Acquia Personalization: Client ID.
if (\Drupal::moduleHandler()->moduleExists('acquia_perz')) {
$settings[] = [
'setting' => 'AcquiaLift.liftWebIdentity.tc_ptid',
'label' => 'Acquia Personalization: Client ID',
];
}
// Include Drupal: User ID as an example.
if (empty($settings)) {
$settings[] = [
'setting' => 'drupalSettings.user.uid',
'label' => 'Drupal: User ID',
];
}
/** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */ /** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */
$third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager'); $third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager');
$third_party_settings_manager->setThirdPartySetting( $third_party_settings_manager
'webform_javascript_setting', ->setThirdPartySetting('webform_javascript_setting', 'settings', $settings);
'settings',
[
[
'setting' => 'drupalSettings.user.uid',
'label' => 'Drupal: User ID',
],
],
);
} }
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
* Provides an element that pulls a JavaScript object''s setting into a hidden field. * Provides an element that pulls a JavaScript object''s setting into a hidden field.
*/ */
declare(strict_types = 1);
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
/** /**
* Implements hook_webform_admin_third_party_settings_form_alter(). * Implements hook_webform_admin_third_party_settings_form_alter().
*/ */
function webform_javascript_setting_webform_admin_third_party_settings_form_alter(&$form, FormStateInterface $form_state) { function webform_javascript_setting_webform_admin_third_party_settings_form_alter(array &$form, FormStateInterface $form_state): void {
/** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */ /** @var \Drupal\webform\WebformThirdPartySettingsManagerInterface $third_party_settings_manager */
$third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager'); $third_party_settings_manager = \Drupal::service('webform.third_party_settings_manager');
$settings = $third_party_settings_manager->getThirdPartySetting('webform_javascript_setting', 'settings'); $settings = $third_party_settings_manager->getThirdPartySetting('webform_javascript_setting', 'settings');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment