Issue #2163035 by Berdir: Remove $user->theme and Drupal\user\Theme\UserNegotiator.
parent
0cecf582b9
commit
e46d6bfa19
|
@ -49,7 +49,6 @@ class TextPlainUnitTest extends DrupalUnitTestBase {
|
|||
// Configure the theme system.
|
||||
$this->installConfig(array('system', 'field'));
|
||||
$this->installSchema('entity_test', 'entity_test');
|
||||
$this->installSchema('user', 'users');
|
||||
|
||||
// @todo Add helper methods for all of the following.
|
||||
|
||||
|
|
|
@ -266,13 +266,6 @@ class User extends ContentEntityBase implements UserInterface {
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefaultTheme() {
|
||||
return $this->get('theme')->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -482,11 +475,6 @@ class User extends ContentEntityBase implements UserInterface {
|
|||
->setLabel(t('Signature format'))
|
||||
->setDescription(t('The signature format of this user.'));
|
||||
|
||||
$fields['theme'] = FieldDefinition::create('string')
|
||||
->setLabel(t('Theme'))
|
||||
->setDescription(t('The default theme of this user.'))
|
||||
->setPropertyConstraints('value', array('Length' => array('max' => DRUPAL_EXTENSION_NAME_MAX_LENGTH)));
|
||||
|
||||
$fields['timezone'] = FieldDefinition::create('string')
|
||||
->setLabel(t('Timezone'))
|
||||
->setDescription(t('The timezone of this user.'))
|
||||
|
|
|
@ -182,7 +182,6 @@ class UserRegistrationTest extends WebTestBase {
|
|||
$new_user = reset($accounts);
|
||||
$this->assertEqual($new_user->getUsername(), $name, 'Username matches.');
|
||||
$this->assertEqual($new_user->getEmail(), $mail, 'E-mail address matches.');
|
||||
$this->assertEqual($new_user->theme->value, '', 'Correct theme field.');
|
||||
$this->assertEqual($new_user->getSignature(), '', 'Correct signature field.');
|
||||
$this->assertTrue(($new_user->getCreatedTime() > REQUEST_TIME - 20 ), 'Correct creation time.');
|
||||
$this->assertEqual($new_user->isActive(), $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.');
|
||||
|
|
|
@ -125,10 +125,6 @@ class UserValidationTest extends DrupalUnitTestBase {
|
|||
$this->assertLengthViolation($user, 'signature', 255);
|
||||
$user->set('signature', NULL);
|
||||
|
||||
$user->set('theme', $this->randomString(DRUPAL_EXTENSION_NAME_MAX_LENGTH + 1));
|
||||
$this->assertLengthViolation($user, 'theme', DRUPAL_EXTENSION_NAME_MAX_LENGTH);
|
||||
$user->set('theme', NULL);
|
||||
|
||||
$user->set('timezone', $this->randomString(33));
|
||||
$this->assertLengthViolation($user, 'timezone', 32);
|
||||
$user->set('timezone', NULL);
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\user\Theme\UserNegotiator.
|
||||
*/
|
||||
|
||||
namespace Drupal\user\Theme;
|
||||
|
||||
use Drupal\Core\Entity\EntityManager;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Theme\ActiveTheme;
|
||||
use Drupal\Core\Theme\ThemeNegotiatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Defines the theme negotiator service for theme configured per user.
|
||||
*/
|
||||
class UserNegotiator implements ThemeNegotiatorInterface {
|
||||
|
||||
/**
|
||||
* The user storage controller.
|
||||
*
|
||||
* @var \Drupal\user\UserStorageControllerInterface
|
||||
*/
|
||||
protected $userStorageController;
|
||||
|
||||
/**
|
||||
* The current user.
|
||||
*
|
||||
* @var \Drupal\Core\Session\AccountInterface
|
||||
*/
|
||||
protected $currentUser;
|
||||
|
||||
/**
|
||||
* Constructs a UserNegotiator object.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityManager $entity_manager
|
||||
* The entity manager
|
||||
* @param \Drupal\Core\Session\AccountInterface $current_user
|
||||
* The current user.
|
||||
*/
|
||||
public function __construct(EntityManager $entity_manager, AccountInterface $current_user) {
|
||||
$this->userStorageController = $entity_manager->getStorageController('user');
|
||||
$this->currentUser = $current_user;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function applies(Request $request) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function determineActiveTheme(Request $request) {
|
||||
if ($user = $this->userStorageController->load($this->currentUser->id())) {;
|
||||
// Only select the user selected theme if it is available in the
|
||||
// list of themes that can be accessed.
|
||||
if (!empty($user->theme) && drupal_theme_access($user->theme)) {
|
||||
return $user->theme;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -83,14 +83,6 @@ interface UserInterface extends ContentEntityInterface, AccountInterface {
|
|||
*/
|
||||
public function setEmail($mail);
|
||||
|
||||
/**
|
||||
* Returns the default theme of the user.
|
||||
*
|
||||
* @return string
|
||||
* Name of the theme.
|
||||
*/
|
||||
public function getDefaultTheme();
|
||||
|
||||
/**
|
||||
* Returns the user signature.
|
||||
*
|
||||
|
|
|
@ -58,13 +58,6 @@ function user_schema() {
|
|||
'default' => '',
|
||||
'description' => "User's e-mail address.",
|
||||
),
|
||||
'theme' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => "User's default theme.",
|
||||
),
|
||||
'signature' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
|
@ -998,16 +991,6 @@ function user_update_8019() {
|
|||
db_change_field('users_data', 'module', 'module', $spec);
|
||||
}
|
||||
|
||||
if (db_field_exists('users', 'theme')) {
|
||||
$spec = array(
|
||||
'type' => 'varchar',
|
||||
'length' => 50,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
'description' => "User's default theme.",
|
||||
);
|
||||
db_change_field('users', 'theme', 'theme', $spec);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,11 +25,6 @@ services:
|
|||
class: Drupal\user\EventSubscriber\MaintenanceModeSubscriber
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
theme.negotiator.user:
|
||||
class: Drupal\user\Theme\UserNegotiator
|
||||
arguments: ['@entity.manager', '@current_user']
|
||||
tags:
|
||||
- { name: theme_negotiator, priority: -50 }
|
||||
theme.negotiator.admin_theme:
|
||||
class: Drupal\user\Theme\AdminNegotiator
|
||||
arguments: ['@current_user', '@config.factory', '@entity.manager']
|
||||
|
|
|
@ -19,7 +19,7 @@ class FieldCounterTest extends ViewUnitTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'field');
|
||||
public static $modules = array('user');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
|
@ -36,12 +36,6 @@ class FieldCounterTest extends ViewUnitTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('user', 'users');
|
||||
}
|
||||
|
||||
function testSimple() {
|
||||
$view = views_get_view('test_view');
|
||||
$view->setDisplay();
|
||||
|
|
|
@ -17,7 +17,7 @@ use Drupal\views\Plugin\views\field\FieldPluginBase;
|
|||
*/
|
||||
class FieldUnitTest extends ViewUnitTestBase {
|
||||
|
||||
public static $modules = array('user', 'field');
|
||||
public static $modules = array('user');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
|
@ -38,12 +38,6 @@ class FieldUnitTest extends ViewUnitTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('user', 'users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::viewsData().
|
||||
*/
|
||||
|
|
|
@ -59,7 +59,6 @@ class DisplayPageTest extends ViewUnitTestBase {
|
|||
// Setup the needed tables in order to make the drupal router working.
|
||||
$this->installSchema('system', array('router', 'menu_router', 'url_alias'));
|
||||
$this->installSchema('menu_link', 'menu_links');
|
||||
$this->installSchema('user', 'users');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue