You are here

public function WebformSubmissionStorage::getCustomSetting in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformSubmissionStorage.php \Drupal\webform\WebformSubmissionStorage::getCustomSetting()

Get customize setting.

Parameters

string $name: Custom settings name.

mixed $default: Custom settings default value.

\Drupal\webform\WebformInterface|null $webform: A webform.

\Drupal\Core\Entity\EntityInterface|null $source_entity: A webform submission source entity.

Return value

mixed Custom setting.

Overrides WebformSubmissionStorageInterface::getCustomSetting

1 call to WebformSubmissionStorage::getCustomSetting()
WebformSubmissionStorage::getCustomColumns in src/WebformSubmissionStorage.php
Get customized submission columns used to display custom table.

File

src/WebformSubmissionStorage.php, line 891

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function getCustomSetting($name, $default, WebformInterface $webform = NULL, EntityInterface $source_entity = NULL) {

  // Return the default value is webform and source entity is not defined.
  if (!$webform && !$source_entity) {
    return $default;
  }
  $results_customize = $webform
    ->getSetting('results_customize', TRUE);
  $key = "results.custom.{$name}";
  if (!$source_entity) {
    if ($results_customize && $webform
      ->hasUserData($key)) {
      return $webform
        ->getUserData($key);
    }
    elseif ($webform
      ->hasState($key)) {
      return $webform
        ->getState($key);
    }
    else {
      return $default;
    }
  }
  $source_entity_key = $key . '.' . $source_entity
    ->getEntityTypeId() . '.' . $source_entity
    ->id();
  if ($results_customize && $webform
    ->hasUserData($source_entity_key)) {
    return $webform
      ->getUserData($source_entity_key);
  }
  elseif ($webform
    ->hasState($source_entity_key)) {
    return $webform
      ->getState($source_entity_key);
  }
  elseif ($webform
    ->getState('results.custom.default', FALSE)) {
    return $webform
      ->getState($key, $default);
  }
  else {
    return $default;
  }
}