diff -u b/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php --- b/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -7,10 +7,12 @@ namespace Drupal\system\Controller; -use Drupal\Core\Access\CsrfTokenGenerator; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Theme\ThemeAccessCheck; +use Drupal\system\Form\ThemeAdminForm; +use Drupal\Core\Access\CsrfTokenGenerator; use Drupal\system\SystemManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -42,6 +44,13 @@ protected $tokenGenerator; /** + * The theme access checker service. + * + * @var \Drupal\Core\Theme\ThemeAccessCheck + */ + protected $themeAccess; + + /** * Constructs a new SystemController. * * @param \Drupal\system\SystemManager $systemManager @@ -50,11 +59,14 @@ * The entity query object. * @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator * The token generator service. + * @param \Drupal\Core\Theme\ThemeAccessCheck $theme_access + * The theme access checker service. */ - public function __construct(SystemManager $systemManager, QueryFactory $queryFactory, CsrfTokenGenerator $token_generator) { + public function __construct(SystemManager $systemManager, QueryFactory $queryFactory, CsrfTokenGenerator $token_generator, ThemeAccessCheck $theme_access) { $this->systemManager = $systemManager; $this->queryFactory = $queryFactory; $this->tokenGenerator = $token_generator; + $this->themeAccess = $theme_access; } /** @@ -64,7 +76,8 @@ return new static( $container->get('system.manager'), $container->get('entity.query'), - $container->get('csrf_token') + $container->get('csrf_token'), + $container->get('access_check.theme') ); } @@ -218,7 +231,7 @@ if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) { // Create the operations links. $query['theme'] = $theme->name; - if (drupal_theme_access($theme)) { + if ($this->themeAccess->checkAccess($theme->name)) { $theme->operations[] = array( 'title' => $this->t('Settings'), 'href' => 'admin/appearance/settings/' . $theme->name, @@ -293,7 +306,7 @@ '#theme_groups' => $theme_groups, '#theme_group_titles' => $theme_group_titles, ); - $build[] = drupal_get_form('system_themes_admin_form', $admin_theme_options); + $build[] = drupal_get_form(new ThemeAdminForm(), $admin_theme_options); return $build; } diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2690,41 +2690,6 @@ } /** - * Form to select the administration theme. - * - * @ingroup forms - * @see system_themes_admin_form_submit() - */ -function system_themes_admin_form($form, &$form_state, $theme_options) { - // Administration theme settings. - $form['admin_theme'] = array( - '#type' => 'details', - '#title' => t('Administration theme'), - ); - $form['admin_theme']['admin_theme'] = array( - '#type' => 'select', - '#options' => array(0 => t('Default theme')) + $theme_options, - '#title' => t('Administration theme'), - '#description' => t('Choose "Default theme" to always use the same theme as the rest of the site.'), - '#default_value' => Drupal::config('system.theme')->get('admin'), - ); - $form['admin_theme']['actions'] = array('#type' => 'actions'); - $form['admin_theme']['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Save configuration'), - ); - return $form; -} - -/** - * Process system_themes_admin_form form submissions. - */ -function system_themes_admin_form_submit($form, &$form_state) { - drupal_set_message(t('The configuration options have been saved.')); - Drupal::config('system.theme')->set('admin', $form_state['values']['admin_theme'])->save(); -} - -/** * Returns an array of default theme features. */ function _system_default_theme_features() { only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Form/ThemeAdminForm.php @@ -0,0 +1,56 @@ + 'details', + '#title' => t('Administration theme'), + ); + $form['admin_theme']['admin_theme'] = array( + '#type' => 'select', + '#options' => array(0 => t('Default theme')) + $theme_options, + '#title' => t('Administration theme'), + '#description' => t('Choose "Default theme" to always use the same theme as the rest of the site.'), + '#default_value' => $this->config('system.theme')->get('admin'), + ); + $form['admin_theme']['actions'] = array('#type' => 'actions'); + $form['admin_theme']['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Save configuration'), + ); + return $form; + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, array &$form_state) { + drupal_set_message(t('The configuration options have been saved.')); + $this->config('system.theme')->set('admin', $form_state['values']['admin_theme'])->save(); + } +}