Skip to content
Snippets Groups Projects
Commit a2636d4b authored by Lars Stiebenz's avatar Lars Stiebenz Committed by Daniel Cothran
Browse files

Issue #3399072 by lars.stiebenz, nikathone: Support Drupal's configuration override system

parent fad11d01
No related branches found
No related tags found
1 merge request!69Issue 3399072: Support Drupal's configuration override system
Pipeline #46863 passed with warnings
......@@ -70,7 +70,7 @@ function template_preprocess_charts_chart(&$variables) {
];
$variables['content_prefix'] = $element['#content_prefix'];
$variables['content_suffix'] = $element['#content_suffix'];
$config = \Drupal::service('config.factory')->getEditable('charts.settings');
$config = \Drupal::config('charts.settings');
$variables['debug'] = [];
if (!empty($config->get('advanced.debug'))) {
$variables['debug'] = [
......@@ -141,8 +141,7 @@ function charts_library_info_alter(&$libraries, $extension) {
}
// Only try to apply cdn changes if the cdn requirements is on.
$config = \Drupal::service('config.factory')
->getEditable('charts.settings');
$config = \Drupal::config('charts.settings');
if (!$config->get('advanced.requirements.cdn')) {
return;
}
......
......@@ -14,7 +14,7 @@ function charts_billboard_requirements($phase) {
switch ($phase) {
case 'runtime':
$library_path = charts_billboard_find_library();
$config = \Drupal::service('config.factory')->getEditable('charts.settings');
$config = \Drupal::config('charts.settings');
$cdn = $config->get('advanced.requirements.cdn') ?? FALSE;
if (!$library_path) {
......
......@@ -14,7 +14,7 @@ function charts_c3_requirements($phase) {
switch ($phase) {
case 'runtime':
$library_path = charts_c3_find_library();
$config = \Drupal::service('config.factory')->getEditable('charts.settings');
$config = \Drupal::config('charts.settings');
$cdn = $config->get('advanced.requirements.cdn') ?? FALSE;
if (!$library_path) {
......
......@@ -14,7 +14,7 @@ function charts_chartjs_requirements($phase) {
switch ($phase) {
case 'runtime':
$library_path = charts_chartjs_find_library();
$config = \Drupal::service('config.factory')->getEditable('charts.settings');
$config = \Drupal::config('charts.settings');
$cdn = $config->get('advanced.requirements.cdn') ?? FALSE;
if (!$library_path) {
......
......@@ -14,7 +14,7 @@ function charts_highcharts_requirements($phase) {
switch ($phase) {
case 'runtime':
$library_path = charts_highcharts_find_library();
$config = \Drupal::service('config.factory')->getEditable('charts.settings');
$config = \Drupal::config('charts.settings');
$cdn = $config->get('advanced.requirements.cdn') ?? FALSE;
if (!$library_path) {
......
<?php
namespace Drupal\Tests\charts\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\Tests\charts\Traits\ConfigUpdateTrait;
/**
* Tests that chart configuration can be overridden.
*
* @group charts
*/
class ConfigOverrideTest extends WebDriverTestBase {
use ConfigUpdateTrait;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = [
'charts',
'charts_chartjs',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
}
/**
* Tests that charts config can be overridden.
*/
public function testOverridingConfig() {
$this->drupalLogin($this->rootUser);
// Set up an override of the cdn.
$settings['config']['charts.settings']['advanced']['requirements']['cdn'] = (object) [
'value' => FALSE,
'required' => TRUE,
];
$this->writeSettings($settings);
// Check the error message.
$this->drupalGet('admin/reports/status');
$this->assertSession()->pageTextContains('You are missing the Chart.js library in your Drupal installation directory and you have opted not to use a CDN.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment