Issue #2066145 by mtift: Convert node_admin_theme() to the configuration system.

8.0.x
Nathaniel Catchpole 2013-08-30 16:26:42 +01:00
parent ec9b2e800c
commit cf98e43a9f
10 changed files with 29 additions and 13 deletions

View File

@ -272,7 +272,7 @@ function _book_node_is_removable(EntityInterface $node) {
* Implements hook_admin_paths(). * Implements hook_admin_paths().
*/ */
function book_admin_paths() { function book_admin_paths() {
if (variable_get('node_admin_theme')) { if (Drupal::config('node.settings')->get('use_admin_theme')) {
$paths = array( $paths = array(
'node/*/outline' => TRUE, 'node/*/outline' => TRUE,
'node/*/outline/remove' => TRUE, 'node/*/outline/remove' => TRUE,

View File

@ -1 +1,2 @@
items_per_page: '10' items_per_page: '10'
use_admin_theme: '0'

View File

@ -7,6 +7,9 @@ node.settings:
items_per_page: items_per_page:
type: integer type: integer
label: 'Number of posts on front page' label: 'Number of posts on front page'
use_admin_theme:
type: boolean
label: 'Use admin theme when editing or creating content'
node.type.*: node.type.*:
type: mapping type: mapping

View File

@ -430,7 +430,6 @@ function node_uninstall() {
// Delete remaining general module variables. // Delete remaining general module variables.
Drupal::state()->delete('node.node_access_needs_rebuild'); Drupal::state()->delete('node.node_access_needs_rebuild');
variable_del('node_admin_theme');
variable_del('node_recent_block_count'); variable_del('node_recent_block_count');
// Delete any stored state. // Delete any stored state.
@ -1114,6 +1113,17 @@ function node_update_8020() {
Drupal::state()->set('node.type.locked', $locked); 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" * @} End of "addtogroup updates-7.x-to-8.x"
* The next series of updates should start at 9000. * The next series of updates should start at 9000.

View File

@ -223,7 +223,7 @@ function node_uri(EntityInterface $node) {
* Implements hook_admin_paths(). * Implements hook_admin_paths().
*/ */
function node_admin_paths() { function node_admin_paths() {
if (variable_get('node_admin_theme')) { if (Drupal::config('node.settings')->get('use_admin_theme')) {
$paths = array( $paths = array(
'node/*/edit' => TRUE, 'node/*/edit' => TRUE,
'node/*/delete' => 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() * @see node_form_system_themes_admin_form_submit()
*/ */
function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id) { 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', '#type' => 'checkbox',
'#title' => t('Use the administration theme when editing or creating content'), '#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'; $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() * @see node_form_system_themes_admin_form_alter()
*/ */
function node_form_system_themes_admin_form_submit($form, &$form_state) { 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();
} }
/** /**

View File

@ -35,7 +35,7 @@ class OverlayCloseTest extends WebTestBase {
function testNodeCreation() { function testNodeCreation() {
// Make sure the node creation page is considered an administrative path // Make sure the node creation page is considered an administrative path
// (which will appear in the overlay). // (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 // Create a content type and a user who has permission to create it inside
// the overlay. // the overlay.

View File

@ -74,7 +74,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
function testShortcutQuickLink() { function testShortcutQuickLink() {
theme_enable(array('seven')); theme_enable(array('seven'));
\Drupal::config('system.theme')->set('admin', 'seven')->save(); \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); $link = reset($this->set->links);

View File

@ -183,7 +183,7 @@ class ThemeTest extends WebTestBase {
// Enable an administration theme and show it on the node admin pages. // Enable an administration theme and show it on the node admin pages.
$edit = array( $edit = array(
'admin_theme' => 'seven', 'admin_theme' => 'seven',
'node_admin_theme' => TRUE, 'use_admin_theme' => TRUE,
); );
$this->drupalPost('admin/appearance', $edit, t('Save configuration')); $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. // Disable the admin theme on the node admin pages.
$edit = array( $edit = array(
'node_admin_theme' => FALSE, 'use_admin_theme' => FALSE,
); );
$this->drupalPost('admin/appearance', $edit, t('Save configuration')); $this->drupalPost('admin/appearance', $edit, t('Save configuration'));
@ -217,7 +217,7 @@ class ThemeTest extends WebTestBase {
->save(); ->save();
$edit = array( $edit = array(
'admin_theme' => '0', 'admin_theme' => '0',
'node_admin_theme' => FALSE, 'use_admin_theme' => FALSE,
); );
$this->drupalPost('admin/appearance', $edit, t('Save configuration')); $this->drupalPost('admin/appearance', $edit, t('Save configuration'));

View File

@ -98,7 +98,7 @@ function _translation_tab_access(NodeInterface $node) {
* Implements hook_admin_paths(). * Implements hook_admin_paths().
*/ */
function translation_admin_paths() { function translation_admin_paths() {
if (variable_get('node_admin_theme')) { if (Drupal::config('node.settings')->get('use_admin_theme')) {
$paths = array( $paths = array(
'node/*/translate' => TRUE, 'node/*/translate' => TRUE,
); );

View File

@ -85,5 +85,5 @@ function standard_install() {
// Enable the admin theme. // Enable the admin theme.
theme_enable(array('seven')); theme_enable(array('seven'));
Drupal::config('system.theme')->set('admin', 'seven')->save(); Drupal::config('system.theme')->set('admin', 'seven')->save();
variable_set('node_admin_theme', '1'); Drupal::config('node.settings')->set('use_admin_theme', '1')->save();
} }