diff -u b/core/modules/shortcut/src/ShortcutSetStorage.php b/core/modules/shortcut/src/ShortcutSetStorage.php --- b/core/modules/shortcut/src/ShortcutSetStorage.php +++ b/core/modules/shortcut/src/ShortcutSetStorage.php @@ -9,6 +9,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\Database\Connection; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -24,6 +25,13 @@ protected $moduleHandler; /** + * The database connection. + * + * @var \Drupal\Core\Database\Connection + */ + protected $database; + + /** * Constructs a ShortcutSetStorageController object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info @@ -37,10 +45,11 @@ * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityTypeInterface $entity_info, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager) { + public function __construct(EntityTypeInterface $entity_info, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager, Connection $database) { parent::__construct($entity_info, $config_factory, $uuid_service, $language_manager); $this->moduleHandler = $module_handler; + $this->database = $database; } /** @@ -52,7 +61,8 @@ $container->get('config.factory'), $container->get('uuid'), $container->get('module_handler'), - $container->get('language_manager') + $container->get('language_manager'), + $container->get('database') ); } @@ -62,7 +72,7 @@ public function deleteAssignedShortcutSets(ShortcutSetInterface $entity) { // First, delete any user assignments for this set, so that each of these // users will go back to using whatever default set applies. - $query = \Drupal::database()->delete('shortcut_set_users'); + $query = $this->database->delete('shortcut_set_users'); $query->condition('set_name', $entity->id()); $query->execute(); } @@ -82,7 +92,7 @@ * {@inheritdoc} */ public function unassignUser($account) { - $deleted = \Drupal::database()->delete('shortcut_set_users'); + $deleted = $this->database->delete('shortcut_set_users'); $deleted->condition('uid', $account->id()); $deleted->execute(); return (bool) $deleted;