Commit 7f00c591 authored by alexpott's avatar alexpott

Issue #2218655 by sun, effulgentsia, jessebeach: Core expects $theme.settings...

Issue #2218655 by sun, effulgentsia, jessebeach: Core expects $theme.settings default config file to exist.
parent 5476dca3
......@@ -101,12 +101,69 @@ action_configuration_default:
sequence:
- type: string
theme_settings_default:
theme_settings:
type: mapping
mapping:
shortcut_module_link:
type: boolean
label: 'Shortcut module link'
favicon:
type: mapping
label: 'Shortcut icon settings'
mapping:
mimetype:
type: string
label: 'MIME type'
path:
type: string
label: 'Path'
url:
type: string
label: 'URL'
use_default:
type: boolean
label: 'Use the default shortcut icon supplied by the theme'
features:
type: mapping
label: 'Shortcut icon settings'
mapping:
comment_user_picture:
type: boolean
label: 'User pictures in comments'
comment_user_verification:
type: boolean
label: 'User verification status in comments'
favicon:
type: boolean
label: 'Shortcut icon'
logo:
type: boolean
label: 'Logo'
name:
type: boolean
label: 'Site name'
node_user_picture:
type: boolean
label: 'User pictures in posts'
main_menu:
type: boolean
label: 'Main menu'
secondary_menu:
type: boolean
label: 'Secondary menu'
slogan:
type: boolean
label: 'Site slogan'
logo:
type: mapping
label: 'Shortcut icon settings'
mapping:
path:
type: string
label: 'Logo path'
url:
type: uri
label: 'URL'
use_default:
type: boolean
label: 'Use default'
theme_breakpoints_default:
type: sequence
......
......@@ -12,6 +12,7 @@
use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\StorageException;
use Drupal\Core\Language\Language;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ExtensionNameLengthException;
......@@ -862,6 +863,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
else {
$theme_keys = array($theme);
}
// Read hard-coded default settings from the theme info files.
foreach ($theme_keys as $theme_key) {
if (!empty($themes[$theme_key]->info['settings'])) {
$cache[$theme]->merge($themes[$theme_key]->info['settings']);
......@@ -873,12 +875,17 @@ function theme_get_setting($setting_name, $theme = NULL) {
$cache[$theme]->merge(\Drupal::config('system.theme.global')->get());
if ($theme) {
// Get the saved theme-specific settings from the configuration system.
$cache[$theme]->merge(\Drupal::config($theme . '.settings')->get());
// Retrieve configured theme-specific settings, if any.
try {
if ($theme_settings = \Drupal::config($theme . '.settings')->get()) {
$cache[$theme]->merge($theme_settings);
}
}
catch (StorageException $e) {
}
// If the theme does not support a particular feature, override the global
// setting and set the value to NULL.
//$supports = $cache[$theme]->get('supports');
if (!empty($theme_object->info['features'])) {
foreach (_system_default_theme_features() as $feature) {
if (!in_array($feature, $theme_object->info['features'])) {
......
......@@ -385,66 +385,5 @@ system.mail:
label: 'Default'
system.theme.global:
type: mapping
type: theme_settings
label: 'Theme global settings'
mapping:
favicon:
type: mapping
label: 'Shortcut icon settings'
mapping:
mimetype:
type: string
label: 'MIME type'
path:
type: string
label: 'Path'
url:
type: string
label: 'URL'
use_default:
type: boolean
label: 'Use the default shortcut icon supplied by the theme'
features:
type: mapping
label: 'Shortcut icon settings'
mapping:
comment_user_picture:
type: boolean
label: 'User pictures in comments'
comment_user_verification:
type: boolean
label: 'User verification status in comments'
favicon:
type: boolean
label: 'Shortcut icon'
logo:
type: boolean
label: 'Logo'
name:
type: boolean
label: 'Site name'
node_user_picture:
type: boolean
label: 'User pictures in posts'
main_menu:
type: boolean
label: 'Main menu'
secondary_menu:
type: boolean
label: 'Secondary menu'
slogan:
type: boolean
label: 'Site slogan'
logo:
type: mapping
label: 'Shortcut icon settings'
mapping:
path:
type: string
label: 'Logo path'
url:
type: uri
label: 'URL'
use_default:
type: boolean
label: 'Use default'
<?php
/**
* @file
* Contains \Drupal\system\Tests\Theme\ThemeSettingsTest.
*/
namespace Drupal\system\Tests\Theme;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\simpletest\DrupalUnitTestBase;
/**
* Tests theme settings functionality.
*/
class ThemeSettingsTest extends DrupalUnitTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system');
/**
* List of discovered themes.
*
* @var array
*/
protected $availableThemes;
public static function getInfo() {
return array(
'name' => 'Theme settings',
'description' => 'Tests theme settings functionality.',
'group' => 'Theme',
);
}
function setUp() {
parent::setUp();
// Theme settings rely on System module's system.theme.global configuration.
$this->installConfig(array('system'));
if (!isset($this->availableThemes)) {
$discovery = new ExtensionDiscovery();
$this->availableThemes = $discovery->scan('theme');
}
}
/**
* Tests that $theme.settings are imported and used as default theme settings.
*/
function testDefaultConfig() {
$name = 'test_basetheme';
$path = $this->availableThemes[$name]->getPath();
$this->assertTrue(file_exists("$path/config/$name.settings.yml"));
$this->container->get('theme_handler')->enable(array($name));
$this->assertIdentical(theme_get_setting('base', $name), 'only');
}
/**
* Tests that the $theme.settings default config file is optional.
*/
function testNoDefaultConfig() {
$name = 'stark';
$path = $this->availableThemes[$name]->getPath();
$this->assertFalse(file_exists("$path/config/$name.settings.yml"));
$this->container->get('theme_handler')->enable(array($name));
$this->assertNotNull(theme_get_setting('features.favicon', $name));
}
}
test_basetheme.settings:
type: theme_settings
label: 'Test base theme settings'
mapping:
base:
type: string
label: 'Base theme setting'
......@@ -35,6 +35,6 @@ regions:
footer_thirdcolumn: 'Footer third column'
footer_fourthcolumn: 'Footer fourth column'
footer: Footer
# @todo D8: Remove once themes have to be installed.
settings:
shortcut_module_link: '0'
shortcut_module_link: false
# @todo There is no UI yet for configuring this, but the setting is included
# here, because ConfigImportUITest requires a non-empty bartik.settings.yml
# file: https://drupal.org/node/2235901.
shortcut_module_link: false
# Schema for the configuration files of the Bartik theme.
bartik.settings:
type: theme_settings_default
type: theme_settings
label: 'Bartik settings'
mapping:
# @todo Module-specific settings should be defined by the module:
# https://drupal.org/node/2235901.
shortcut_module_link:
type: boolean
label: 'Shortcut module link'
# Schema for the configuration files of the Seven theme.
seven.settings:
type: theme_settings_default
type: theme_settings
label: 'Seven settings'
seven.breakpoints:
......
......@@ -15,9 +15,6 @@ stylesheets-override:
- jquery.ui.theme.css
edit_stylesheets:
- edit.css
settings:
# @todo D8: Remove once themes have to be installed.
shortcut_module_link: '1'
regions:
content: Content
help: Help
......@@ -26,3 +23,6 @@ regions:
sidebar_first: 'First sidebar'
regions_hidden:
- sidebar_first
settings:
shortcut_module_link: true
# Schema for the configuration files of the Stark theme.
stark.settings:
type: theme_settings_default
type: theme_settings
label: 'Stark settings'
stark.breakpoints:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment