You are here

public static function WebformContentCreatorUtilities::getDecryptedValue in Webform Content Creator 2.x

Same name and namespace in other branches
  1. 8 src/WebformContentCreatorUtilities.php \Drupal\webform_content_creator\WebformContentCreatorUtilities::getDecryptedValue()
  2. 3.x src/WebformContentCreatorUtilities.php \Drupal\webform_content_creator\WebformContentCreatorUtilities::getDecryptedValue()

Get decrypted value.

Parameters

string $value: Encrypted value.

string $encryption_profile: Encryption profile.

Return value

string Decrypted value

2 calls to WebformContentCreatorUtilities::getDecryptedValue()
WebformContentCreatorEntity::getDecryptionFromProfile in src/Entity/WebformContentCreatorEntity.php
Get decrypted value with the configured encryption profile.
WebformContentCreatorUtilities::getDecryptedTokenValue in src/WebformContentCreatorUtilities.php
Get decrypted values inside text with tokens.

File

src/WebformContentCreatorUtilities.php, line 301

Class

WebformContentCreatorUtilities
Provides useful functions required in Webform content creator module.

Namespace

Drupal\webform_content_creator

Code

public static function getDecryptedValue($value, $encryption_profile) {
  if (empty($value) || empty($encryption_profile)) {
    return '';
  }
  $dec_value = FALSE;
  if (\Drupal::service('module_handler')
    ->moduleExists('encrypt')) {
    $dec_value = \Drupal::service('encryption')
      ->decrypt($value, $encryption_profile);
  }
  if ($dec_value === FALSE) {
    $dec_value = $value;
  }
  return $dec_value;
}