You are here

public function YamlFormMessageManager::log in YAML Form 8

Log message.

Parameters

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

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

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

Overrides YamlFormMessageManagerInterface::log

File

src/YamlFormMessageManager.php, line 235

Class

YamlFormMessageManager
Defines the form message (and login) manager.

Namespace

Drupal\yamlform

Code

public function log($key, $type = 'warning') {
  $yamlform = $this->yamlform;
  $context = [
    'link' => $yamlform
      ->toLink($this
      ->t('Edit'), 'edit-form')
      ->toString(),
  ];
  switch ($key) {
    case YamlFormMessageManagerInterface::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 YamlFormMessageManagerInterface::FORM_SAVE_EXCEPTION:
      $context['%form'] = $yamlform
        ->label();
      $message = '%form is not saving any submitted data and has been disabled.';
      break;
  }
  $this->logger
    ->{$type}($message, $context);
}