diff --git a/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php b/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php index bb6a510..1753596 100644 --- a/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php +++ b/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php @@ -7,10 +7,9 @@ namespace Drupal\system\Controller; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\Config\Config; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\StringTranslation\TranslationInterface; +use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Access\CsrfTokenGenerator; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -18,28 +17,14 @@ /** * Controller for theme handling. */ -class ThemeListingController implements ControllerInterface { +class ThemeListingController extends ControllerBase implements ContainerInjectionInterface { /** - * The system.theme config object. + * The config factory. * - * @var \Drupal\Core\Config\Config + * @var \Drupal\Core\Config\ConfigFactory */ - protected $config; - - /** - * The module handler service. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * The translation service. - * - * @var \Drupal\Core\StringTranslation\TranslationInterface - */ - protected $translation; + protected $configFactory; /** * The token generator manager service. @@ -51,19 +36,13 @@ class ThemeListingController implements ControllerInterface { /** * Constructs a ThemeListingController object. * - * @param \Drupal\Core\Config\Config $config - * The system.theme config object. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. - * @param \Drupal\Core\StringTranslation\TranslationInterface $translation - * The translation manager service. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The config factory. * @param \Drupal\Core\Access\CsrfTokenGenerator * The Csrf token generator. */ - public function __construct(Config $config, ModuleHandlerInterface $module_handler, TranslationInterface $translation, CsrfTokenGenerator $token_generator) { - $this->config = $config; - $this->moduleHandler = $module_handler; - $this->translation = $translation; + public function __construct(ConfigFactory $config_factory, CsrfTokenGenerator $token_generator) { + $this->configFactory = $config_factory; $this->tokenGenerator = $token_generator; } @@ -72,9 +51,7 @@ public function __construct(Config $config, ModuleHandlerInterface $module_handl */ public static function create(ContainerInterface $container) { return new static( - $container->get('config.factory')->get('system.theme'), - $container->get('module_handler'), - $container->get('string_translation'), + $container->get('config.factory'), $container->get('csrf_token') ); } @@ -86,13 +63,14 @@ public static function create(ContainerInterface $container) { * A HTML string of the theme listing page. */ public function listingPage() { + $config = $this->configFactory->get('system.theme'); // Get current list of themes. $themes = system_rebuild_theme_data(); uasort($themes, 'system_sort_modules_by_info_name'); - $theme_default = $this->config->get('default'); + $theme_default = $config->get('default'); $theme_groups = array(); - $admin_theme = $this->config->get('admin'); + $admin_theme = $config->get('admin'); foreach ($themes as &$theme) { if (!empty($theme->info['hidden'])) { @@ -115,8 +93,8 @@ public function listingPage() { if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) { $theme->screenshot = array( 'uri' => $themes[$theme_key]->info['screenshot'], - 'alt' => $this->translation->translate('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), - 'title' => $this->translation->translate('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), + 'alt' => $this->t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), + 'title' => $this->t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), 'attributes' => array('class' => array('screenshot')), ); break; @@ -141,42 +119,42 @@ public function listingPage() { $query['theme'] = $theme->name; if (drupal_theme_access($theme)) { $theme->operations[] = array( - 'title' => $this->translation->translate('Settings'), + 'title' => $this->t('Settings'), 'href' => 'admin/appearance/settings/' . $theme->name, - 'attributes' => array('title' => $this->translation->translate('Settings for !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Settings for !theme theme', array('!theme' => $theme->info['name']))), ); } if (!empty($theme->status)) { if (!$theme->is_default) { if ($theme->name != $admin_theme) { $theme->operations[] = array( - 'title' => $this->translation->translate('Disable'), + 'title' => $this->t('Disable'), 'href' => 'admin/appearance/disable', 'query' => $query, - 'attributes' => array('title' => $this->translation->translate('Disable !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Disable !theme theme', array('!theme' => $theme->info['name']))), ); } $theme->operations[] = array( - 'title' => $this->translation->translate('Set default'), + 'title' => $this->t('Set default'), 'href' => 'admin/appearance/default', 'query' => $query, - 'attributes' => array('title' => $this->translation->translate('Set !theme as default theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Set !theme as default theme', array('!theme' => $theme->info['name']))), ); } $admin_theme_options[$theme->name] = $theme->info['name']; } else { $theme->operations[] = array( - 'title' => $this->translation->translate('Enable'), + 'title' => $this->t('Enable'), 'href' => 'admin/appearance/enable', 'query' => $query, - 'attributes' => array('title' => $this->translation->translate('Enable !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Enable !theme theme', array('!theme' => $theme->info['name']))), ); $theme->operations[] = array( - 'title' => $this->translation->translate('Enable and set default'), + 'title' => $this->t('Enable and set default'), 'href' => 'admin/appearance/default', 'query' => $query, - 'attributes' => array('title' => $this->translation->translate('Enable !theme as default theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->t('Enable !theme as default theme', array('!theme' => $theme->info['name']))), ); } } @@ -186,11 +164,11 @@ public function listingPage() { $theme->classes = array(); if ($theme->is_default) { $theme->classes[] = 'theme-default'; - $theme->notes[] = $this->translation->translate('default theme'); + $theme->notes[] = $this->t('default theme'); } if ($theme->name == $admin_theme || ($theme->is_default && $admin_theme == '0')) { $theme->classes[] = 'theme-admin'; - $theme->notes[] = $this->translation->translate('admin theme'); + $theme->notes[] = $this->t('admin theme'); } // Sort enabled and disabled themes into their own groups. @@ -206,7 +184,7 @@ public function listingPage() { } uasort($theme_groups['enabled'], array($this, 'systemSortThemes')); - $this->moduleHandler->alter('system_themes_page', $theme_groups); + $this->moduleHandler()->alter('system_themes_page', $theme_groups); $build = array(); $build[] = array(