function ModulesEnabledTrait::modulesEnabledConfirmationMessage

Same name in other branches
  1. 9 core/modules/system/src/Form/ModulesEnabledTrait.php \Drupal\system\Form\ModulesEnabledTrait::modulesEnabledConfirmationMessage()
  2. 11.x core/modules/system/src/Form/ModulesEnabledTrait.php \Drupal\system\Form\ModulesEnabledTrait::modulesEnabledConfirmationMessage()

Provides a confirmation message after modules have been enabled.

Parameters

string[] $modules: Enabled module names, keyed by machine names.

Return value

\Drupal\Core\StringTranslation\PluralTranslatableMarkup A confirmation message. If any of the enabled modules have permissions that the current user can manage, then include a link to the permissions page for those modules.

2 calls to ModulesEnabledTrait::modulesEnabledConfirmationMessage()
ModulesListConfirmForm::submitForm in core/modules/system/src/Form/ModulesListConfirmForm.php
Form submission handler.
ModulesListForm::submitForm in core/modules/system/src/Form/ModulesListForm.php
Form submission handler.

File

core/modules/system/src/Form/ModulesEnabledTrait.php, line 38

Class

ModulesEnabledTrait
Provides helpers for enabling modules.

Namespace

Drupal\system\Form

Code

protected function modulesEnabledConfirmationMessage(array $modules) : PluralTranslatableMarkup {
    $machine_names = implode(',', array_keys($modules));
    $url = Url::fromRoute('user.admin_permissions.module', [
        'modules' => $machine_names,
    ]);
    $module_names = implode(', ', array_values($modules));
    $t_args = [
        '%name' => $module_names,
        '%names' => $module_names,
    ];
    if ($url->access($this->currentUser())) {
        return $this->formatPlural(count($modules), 'Module %name has been installed. Configure <a href=":link">related permissions</a>.', '@count modules have been installed: %names. Configure <a href=":link">related permissions</a>.', $t_args + [
            ':link' => $url->toString(),
        ]);
    }
    return $this->formatPlural(count($modules), 'Module %name has been installed.', '@count modules have been installed: %names.', $t_args);
}

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