function ConfigSingleImportForm::getQuestion

Same name and namespace in other branches
  1. 9 core/modules/config/src/Form/ConfigSingleImportForm.php \Drupal\config\Form\ConfigSingleImportForm::getQuestion()
  2. 8.9.x core/modules/config/src/Form/ConfigSingleImportForm.php \Drupal\config\Form\ConfigSingleImportForm::getQuestion()
  3. 11.x 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 222

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.