diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SwitchShortcutSet.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SwitchShortcutSet.php index 7546d06..aba77e0 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SwitchShortcutSet.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SwitchShortcutSet.php @@ -10,7 +10,8 @@ use Drupal\Component\Utility\String; use Drupal\Core\Access\AccessInterface; use Drupal\Core\Form\FormBase; -use Drupal\shortcut\ShortcutSetStorageControllerInterface; +use Drupal\Core\Session\AccountInterface; +use Drupal\shortcut\ShortcutSetStorageInterface; use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -29,17 +30,17 @@ class SwitchShortcutSet extends FormBase { /** * The shortcut storage controller. * - * @var \Drupal\shortcut\ShortcutSetStorageControllerInterface + * @var \Drupal\shortcut\ShortcutSetStorageInterface */ protected $storageController; /** * Constructs a SwitchShortcutSet object. * - * @param \Drupal\shortcut\ShortcutSetStorageControllerInterface $shortcut_set_storage_controller + * @param \Drupal\shortcut\ShortcutSetStorageInterface $shortcut_set_storage_controller * The shortcut set storage controller. */ - public function __construct(ShortcutSetStorageControllerInterface $shortcut_set_storage_controller) { + public function __construct(ShortcutSetStorageInterface $shortcut_set_storage_controller) { $this->storageController = $shortcut_set_storage_controller; } @@ -139,6 +140,21 @@ public function buildForm(array $form, array &$form_state, UserInterface $user = } /** + * Determines if a shortcut set exists already. + * + * @param string $id + * The set ID to check. + * + * @return bool + * TRUE if the shortcut set exists, FALSE otherwise. + */ + public function exists($id) { + return (bool) $this->storageController->getQuery() + ->condition('id', $id) + ->execute(); + } + + /** * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { @@ -206,30 +222,15 @@ public function submitForm(array &$form, array &$form_state) { } /** - * Determines if a shortcut set exists already. - * - * @param string $id - * The set ID to check. - * - * @return bool - * TRUE if the shortcut set exists, FALSE otherwise. - */ - public function exists($id) { - return (bool) $this->storageController->getQuery() - ->condition('id', $id) - ->execute(); - } - - /** * Checks access for the shortcut set switch form. * - * @param \Drupal\user\UserInterface $user + * @param \Drupal\Core\Session\AccountInterface $account * The user whose shortcut sets are being switched. * - * @return bool|null + * @return mixed * AccessInterface::ALLOW, AccessInterface::DENY, or AccessInterface::KILL. */ - public function checkAccess(UserInterface $user) { + public function checkAccess(AccountInterface $account) { $account = $this->currentUser(); if ($account->hasPermission('administer shortcuts')) { // Administrators can switch anyone's shortcut set. @@ -241,7 +242,7 @@ public function checkAccess(UserInterface $user) { return AccessInterface::DENY; } - if ($account->id() == $user->id()) { + if ($account->id() == $account->id()) { // Users with the 'switch shortcut sets' permission can switch their own // shortcuts sets. return AccessInterface::ALLOW; diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetStorage.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetStorage.php index 610b264..dba5752 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetStorage.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetStorage.php @@ -7,7 +7,15 @@ namespace Drupal\shortcut; +use Drupal\Component\Uuid\UuidInterface; +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Entity\ConfigEntityStorage; +use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Language\LanguageManagerInterface; +use Drupal\Core\Session\AccountInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a storage for shortcut_set entities. @@ -34,9 +42,11 @@ class ShortcutSetStorage extends ConfigEntityStorage implements ShortcutSetStora * The UUID service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. + * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager + * The language manager. */ - public function __construct(EntityTypeInterface $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_info, $config_factory, $config_storage, $uuid_service); + public function __construct(EntityTypeInterface $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager) { + parent::__construct($entity_info, $config_factory, $config_storage, $uuid_service, $language_manager); $this->moduleHandler = $module_handler; } @@ -50,7 +60,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $container->get('config.factory'), $container->get('config.storage'), $container->get('uuid'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('language_manager') ); }