summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-10-31 11:22:09 (GMT)
committerAlex Pott2016-10-31 11:22:09 (GMT)
commit73078ed5b22e74c0351aa954fb5ff52c987968b1 (patch)
treedfcb92741b3306c4d8b70bceebc0168e54b34275
parenta4dd7f286042b9eaf8757eab352ac7b29724dd06 (diff)
Issue #2731861 by maxocub, felribeiro, aneek, alauzon, rajeshwari10, malavya, Sagar Ramgade, visabhishek, pashupathi nath gajawada, starshaped, quietone: Maintenance mode description shows wrong permission name
-rw-r--r--core/modules/system/src/Form/SiteMaintenanceModeForm.php20
-rw-r--r--core/modules/system/src/Tests/System/SiteMaintenanceTest.php9
2 files changed, 26 insertions, 3 deletions
diff --git a/core/modules/system/src/Form/SiteMaintenanceModeForm.php b/core/modules/system/src/Form/SiteMaintenanceModeForm.php
index 02c5a9a..0d0b2af 100644
--- a/core/modules/system/src/Form/SiteMaintenanceModeForm.php
+++ b/core/modules/system/src/Form/SiteMaintenanceModeForm.php
@@ -6,6 +6,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Form\ConfigFormBase;
+use Drupal\user\PermissionHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -21,16 +22,26 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
protected $state;
/**
+ * The permission handler.
+ *
+ * @var \Drupal\user\PermissionHandlerInterface
+ */
+ protected $permissionHandler;
+
+ /**
* Constructs a new SiteMaintenanceModeForm.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\State\StateInterface $state
* The state keyvalue collection to use.
+ * @param \Drupal\user\PermissionHandlerInterface $permission_handler
+ * The permission handler.
*/
- public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state) {
+ public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state, PermissionHandlerInterface $permission_handler) {
parent::__construct($config_factory);
$this->state = $state;
+ $this->permissionHandler = $permission_handler;
}
/**
@@ -39,7 +50,8 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
- $container->get('state')
+ $container->get('state'),
+ $container->get('user.permissions')
);
}
/**
@@ -61,11 +73,13 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('system.maintenance');
+ $permissions = $this->permissionHandler->getPermissions();
+ $permission_label = $permissions['access site in maintenance mode']['title'];
$form['maintenance_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Put site into maintenance mode'),
'#default_value' => $this->state->get('system.maintenance_mode'),
- '#description' => t('Visitors will only see the maintenance mode message. Only users with the "Access site in maintenance mode" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array(':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))),
+ '#description' => t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array('@permission-label' => $permission_label, ':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))),
);
$form['maintenance_mode_message'] = array(
'#type' => 'textarea',
diff --git a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php
index fc14b2d..84e3492 100644
--- a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php
+++ b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php
@@ -39,6 +39,15 @@ class SiteMaintenanceTest extends WebTestBase {
* Verifies site maintenance mode functionality.
*/
protected function testSiteMaintenance() {
+
+ // Verify that permission message is displayed.
+ $permission_handler = $this->container->get('user.permissions');
+ $permissions = $permission_handler->getPermissions();
+ $permission_label = $permissions['access site in maintenance mode']['title'];
+ $permission_message = t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array('@permission-label' => $permission_label, ':permissions-url' => \Drupal::url('user.admin_permissions'), ':user-login' => \Drupal::url('user.login')));
+ $this->drupalGet(Url::fromRoute('system.site_maintenance_mode'));
+ $this->assertRaw($permission_message, 'Found the permission message.');
+
$this->drupalGet(Url::fromRoute('user.page'));
// JS should be aggregated, so drupal.js is not in the page source.
$links = $this->xpath('//script[contains(@src, :href)]', array(':href' => '/core/misc/drupal.js'));