Skip to content
Snippets Groups Projects
Commit eef01835 authored by Jakob P's avatar Jakob P
Browse files

Issue #2910445 by pfrenssen: Add a warning to the status report if config is writable

parent 633853ad
Branches
Tags
1 merge request!16Resolve #2910445 "Add a warning"
Pipeline #214358 canceled
<?php
/**
* @file
* Install, uninstall, requirements and schema hooks for Config Read-only mode.
*/
use Drupal\Core\Site\Settings;
/**
* Implements hook_requirements().
*/
function config_readonly_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
if (!Settings::get('config_readonly')) {
$requirements['config_readonly'] = [
'title' => t('Config Read-only mode'),
'description' => t('The Config Read-only module is enabled but not active.'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Config is writable'),
];
}
else {
$requirements['config_readonly'] = [
'title' => t('Config Read-only mode'),
'description' => t('The Config Read-only module is enabled and active.'),
'severity' => REQUIREMENT_INFO,
'value' => t('Config is readonly'),
];
}
}
return $requirements;
}
......@@ -141,4 +141,24 @@ class ReadOnlyConfigTest extends ReadOnlyConfigTestBase {
$this->assertSession()->pageTextContains($this->message);
}
/**
* Test the status page to ensure the correct message is displayed.
*
* @see https://www.drupal.org/project/config_readonly/issues/2910445
*/
public function testModuleStatusPage() {
// Verify if we can successfully access file system route.
$status_url = Url::fromRoute('system.status');
$this->drupalGet($status_url);
$this->assertSession()->statusCodeEquals(200);
// Status page displays REQUIREMENT_WARNING because read-only is disabled.
$this->assertSession()->pageTextContains("The Config Read-only module is enabled but not active.");
// Switch forms to read-only.
$this->turnOnReadOnlySetting();
$this->drupalGet($status_url);
// Status page displays REQUIREMENT_INFO because read-only is enabled.
$this->assertSession()->pageTextContains("The Config Read-only module is enabled and active.");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment