From cf98e43a9fdb6e39013bb4d48ba5267de18cd1b5 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 30 Aug 2013 16:26:42 +0100 Subject: [PATCH] Issue #2066145 by mtift: Convert node_admin_theme() to the configuration system. --- core/modules/book/book.module | 2 +- core/modules/node/config/node.settings.yml | 1 + core/modules/node/config/schema/node.schema.yml | 3 +++ core/modules/node/node.install | 12 +++++++++++- core/modules/node/node.module | 10 ++++++---- .../lib/Drupal/overlay/Tests/OverlayCloseTest.php | 2 +- .../lib/Drupal/shortcut/Tests/ShortcutLinksTest.php | 2 +- .../lib/Drupal/system/Tests/System/ThemeTest.php | 6 +++--- core/modules/translation/translation.module | 2 +- core/profiles/standard/standard.install | 2 +- 10 files changed, 29 insertions(+), 13 deletions(-) diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 525056e1555..e57ef548eda 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -272,7 +272,7 @@ function _book_node_is_removable(EntityInterface $node) { * Implements hook_admin_paths(). */ function book_admin_paths() { - if (variable_get('node_admin_theme')) { + if (Drupal::config('node.settings')->get('use_admin_theme')) { $paths = array( 'node/*/outline' => TRUE, 'node/*/outline/remove' => TRUE, diff --git a/core/modules/node/config/node.settings.yml b/core/modules/node/config/node.settings.yml index 956286493c6..76b19d1009b 100644 --- a/core/modules/node/config/node.settings.yml +++ b/core/modules/node/config/node.settings.yml @@ -1 +1,2 @@ items_per_page: '10' +use_admin_theme: '0' diff --git a/core/modules/node/config/schema/node.schema.yml b/core/modules/node/config/schema/node.schema.yml index 2ad1c17763b..c11552e602c 100644 --- a/core/modules/node/config/schema/node.schema.yml +++ b/core/modules/node/config/schema/node.schema.yml @@ -7,6 +7,9 @@ node.settings: items_per_page: type: integer label: 'Number of posts on front page' + use_admin_theme: + type: boolean + label: 'Use admin theme when editing or creating content' node.type.*: type: mapping diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 7b42475417d..02cc7a01a9c 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -430,7 +430,6 @@ function node_uninstall() { // Delete remaining general module variables. Drupal::state()->delete('node.node_access_needs_rebuild'); - variable_del('node_admin_theme'); variable_del('node_recent_block_count'); // Delete any stored state. @@ -1114,6 +1113,17 @@ function node_update_8020() { Drupal::state()->set('node.type.locked', $locked); } +/** + * Converts node_admin_theme variable to config. + * + * @ingroup config_upgrade + */ +function node_update_8021() { + update_variables_to_config('node.settings', array( + 'node_admin_theme' => 'use_admin_theme' + )); +} + /** * @} End of "addtogroup updates-7.x-to-8.x" * The next series of updates should start at 9000. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 44f60e7b928..119f429e1dc 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -223,7 +223,7 @@ function node_uri(EntityInterface $node) { * Implements hook_admin_paths(). */ function node_admin_paths() { - if (variable_get('node_admin_theme')) { + if (Drupal::config('node.settings')->get('use_admin_theme')) { $paths = array( 'node/*/edit' => TRUE, 'node/*/delete' => TRUE, @@ -1900,10 +1900,10 @@ function node_form_system_site_information_settings_form_submit($form, &$form_st * @see node_form_system_themes_admin_form_submit() */ function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id) { - $form['admin_theme']['node_admin_theme'] = array( + $form['admin_theme']['use_admin_theme'] = array( '#type' => 'checkbox', '#title' => t('Use the administration theme when editing or creating content'), - '#default_value' => variable_get('node_admin_theme', '0'), + '#default_value' => Drupal::config('node.settings')->get('use_admin_theme'), ); $form['#submit'][] = 'node_form_system_themes_admin_form_submit'; } @@ -1914,7 +1914,9 @@ function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id * @see node_form_system_themes_admin_form_alter() */ function node_form_system_themes_admin_form_submit($form, &$form_state) { - variable_set('node_admin_theme', $form_state['values']['node_admin_theme']); + Drupal::config('node.settings') + ->set('use_admin_theme', $form_state['values']['use_admin_theme']) + ->save(); } /** diff --git a/core/modules/overlay/lib/Drupal/overlay/Tests/OverlayCloseTest.php b/core/modules/overlay/lib/Drupal/overlay/Tests/OverlayCloseTest.php index e9dbec1e8d7..a16c7201694 100644 --- a/core/modules/overlay/lib/Drupal/overlay/Tests/OverlayCloseTest.php +++ b/core/modules/overlay/lib/Drupal/overlay/Tests/OverlayCloseTest.php @@ -35,7 +35,7 @@ class OverlayCloseTest extends WebTestBase { function testNodeCreation() { // Make sure the node creation page is considered an administrative path // (which will appear in the overlay). - variable_set('node_admin_theme', TRUE); + $this->container->get('config.factory')->get('node.settings')->set('use_admin_theme', '1')->save(); // Create a content type and a user who has permission to create it inside // the overlay. diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index 3f0e5689cad..1ee28c26332 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -74,7 +74,7 @@ class ShortcutLinksTest extends ShortcutTestBase { function testShortcutQuickLink() { theme_enable(array('seven')); \Drupal::config('system.theme')->set('admin', 'seven')->save(); - variable_set('node_admin_theme', TRUE); + $this->container->get('config.factory')->get('node.settings')->set('use_admin_theme', '1')->save(); $link = reset($this->set->links); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php index 4d5aec1a805..d3476f7bd93 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/ThemeTest.php @@ -183,7 +183,7 @@ class ThemeTest extends WebTestBase { // Enable an administration theme and show it on the node admin pages. $edit = array( 'admin_theme' => 'seven', - 'node_admin_theme' => TRUE, + 'use_admin_theme' => TRUE, ); $this->drupalPost('admin/appearance', $edit, t('Save configuration')); @@ -201,7 +201,7 @@ class ThemeTest extends WebTestBase { // Disable the admin theme on the node admin pages. $edit = array( - 'node_admin_theme' => FALSE, + 'use_admin_theme' => FALSE, ); $this->drupalPost('admin/appearance', $edit, t('Save configuration')); @@ -217,7 +217,7 @@ class ThemeTest extends WebTestBase { ->save(); $edit = array( 'admin_theme' => '0', - 'node_admin_theme' => FALSE, + 'use_admin_theme' => FALSE, ); $this->drupalPost('admin/appearance', $edit, t('Save configuration')); diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 093aeee7c9c..9477c84fcf2 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -98,7 +98,7 @@ function _translation_tab_access(NodeInterface $node) { * Implements hook_admin_paths(). */ function translation_admin_paths() { - if (variable_get('node_admin_theme')) { + if (Drupal::config('node.settings')->get('use_admin_theme')) { $paths = array( 'node/*/translate' => TRUE, ); diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index a80beaaff14..af30e20846b 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -85,5 +85,5 @@ function standard_install() { // Enable the admin theme. theme_enable(array('seven')); Drupal::config('system.theme')->set('admin', 'seven')->save(); - variable_set('node_admin_theme', '1'); + Drupal::config('node.settings')->set('use_admin_theme', '1')->save(); }