You are here

public function ConfigSingleImportForm::getQuestion in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config/src/Form/ConfigSingleImportForm.php \Drupal\config\Form\ConfigSingleImportForm::getQuestion()

Returns the question to ask the user.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The form question. The page title will be set to this value.

Overrides ConfirmFormInterface::getQuestion

File

core/modules/config/src/Form/ConfigSingleImportForm.php, line 215

Class

ConfigSingleImportForm
Provides a form for importing a single configuration file.

Namespace

Drupal\config\Form

Code

public function getQuestion() {
  if ($this->data['config_type'] === 'system.simple') {
    $name = $this->data['config_name'];
    $type = $this
      ->t('simple configuration');
  }
  else {
    $definition = $this->entityTypeManager
      ->getDefinition($this->data['config_type']);
    $name = $this->data['import'][$definition
      ->getKey('id')];
    $type = $definition
      ->getSingularLabel();
  }
  $args = [
    '%name' => $name,
    '@type' => strtolower($type),
  ];
  if ($this->configExists) {
    $question = $this
      ->t('Are you sure you want to update the %name @type?', $args);
  }
  else {
    $question = $this
      ->t('Are you sure you want to create a new %name @type?', $args);
  }
  return $question;
}