annotate core/modules/system/src/Theme/DbUpdateNegotiator.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\system\Theme;
Chris@0 4
Chris@0 5 use Drupal\Core\Config\ConfigFactoryInterface;
Chris@0 6 use Drupal\Core\Routing\RouteMatchInterface;
Chris@0 7 use Drupal\Core\Site\Settings;
Chris@0 8 use Drupal\Core\Theme\ThemeNegotiatorInterface;
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Sets the active theme for the database update pages.
Chris@0 12 */
Chris@0 13 class DbUpdateNegotiator implements ThemeNegotiatorInterface {
Chris@0 14
Chris@0 15 /**
Chris@0 16 * The config factory.
Chris@0 17 *
Chris@0 18 * @var \Drupal\Core\Config\ConfigFactoryInterface
Chris@0 19 */
Chris@0 20 protected $configFactory;
Chris@0 21
Chris@0 22 /**
Chris@0 23 * Constructs a DbUpdateNegotiator.
Chris@0 24 *
Chris@0 25 * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
Chris@0 26 * The config factory.
Chris@0 27 */
Chris@0 28 public function __construct(ConfigFactoryInterface $config_factory) {
Chris@0 29 $this->configFactory = $config_factory;
Chris@0 30 }
Chris@0 31
Chris@0 32 /**
Chris@0 33 * {@inheritdoc}
Chris@0 34 */
Chris@0 35 public function applies(RouteMatchInterface $route_match) {
Chris@0 36 return $route_match->getRouteName() == 'system.db_update';
Chris@0 37 }
Chris@0 38
Chris@0 39 /**
Chris@0 40 * {@inheritdoc}
Chris@0 41 */
Chris@0 42 public function determineActiveTheme(RouteMatchInterface $route_match) {
Chris@0 43 $custom_theme = Settings::get('maintenance_theme', 'seven');
Chris@0 44 if (!$custom_theme) {
Chris@0 45 $config = $this->configFactory->get('system.theme');
Chris@0 46 $custom_theme = $config->get('default');
Chris@0 47 }
Chris@0 48
Chris@0 49 return $custom_theme;
Chris@0 50 }
Chris@0 51
Chris@0 52 }