You are here

public function WebformMessageManager::log in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformMessageManager.php \Drupal\webform\WebformMessageManager::log()

Log message.

Parameters

string $key: The name of webform settings message to be logged.

string $type: (optional) The message's type. Defaults to 'warning'. These values are supported:

  • 'notice'.
  • 'warning'.
  • 'error'.

Overrides WebformMessageManagerInterface::log

File

src/WebformMessageManager.php, line 314

Class

WebformMessageManager
Defines the webform message (and login) manager.

Namespace

Drupal\webform

Code

public function log($key, $type = 'warning') {
  $webform = $this->webform;
  $context = [
    'link' => $webform
      ->toLink($this
      ->t('Edit'), 'settings')
      ->toString(),
  ];
  switch ($key) {
    case WebformMessageManagerInterface::FORM_FILE_UPLOAD_EXCEPTION:
      $message = 'To support file uploads the saving of submission must be enabled. <strong>All uploaded load files would be lost</strong> Please either uncheck \'Disable saving of submissions\' or remove all the file upload elements.';
      break;
    case WebformMessageManagerInterface::FORM_SAVE_EXCEPTION:
      $context['%form'] = $webform
        ->label();
      $message = '%form is not saving any submitted data and has been disabled.';
      break;
    case WebformMessageManagerInterface::PREPOPULATE_SOURCE_ENTITY_TYPE:
      $context['%form'] = $webform
        ->label();
      $message = '%form prepopulated source entity is not valid.';
      break;
    case WebformMessageManagerInterface::PREPOPULATE_SOURCE_ENTITY_REQUIRED:
      $context['%form'] = $webform
        ->label();
      $message = '%form prepopulated source entity is required.';
      break;
  }
  $this->logger
    ->{$type}($message, $context);
}