diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetSwitch.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetSwitch.php index 81fde35..0409cd2 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetSwitch.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetSwitch.php @@ -43,6 +43,13 @@ class SetSwitch implements ControllerInterface, FormInterface { protected $storageController; /** + * The user storage controller. + * + * @var \Drupal\user\UserStorageControllerInterface + */ + protected $userStorageController; + + /** * Constructs a SetSwitch object. * * @param \Drupal\Core\Entity\EntityManager $entity_manager @@ -50,6 +57,7 @@ class SetSwitch implements ControllerInterface, FormInterface { */ public function __construct(EntityManager $entity_manager) { $this->storageController = $entity_manager->getStorageController('shortcut'); + $this->userStorageController = $entity_manager->getStorageController('user'); } /** @@ -71,17 +79,17 @@ public function getFormID() { /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, AccountInterface $account = NULL, Request $request = NULL) { + public function buildForm(array $form, array &$form_state, UserInterface $_account = NULL, Request $request = NULL) { global $user; $this->request = $request; - $this->account = $account; + $this->account = $this->userStorageController->load($_account->id())->getBCEntity(); // Prepare the list of shortcut sets. $options = array_map(function ($set) { return String::checkPlain($set->label()); }, $this->storageController->loadMultiple()); - $current_set = shortcut_current_displayed_set($this->account->getBCEntity()); + $current_set = shortcut_current_displayed_set($this->account); // Only administrators can add shortcut sets. $add_access = user_access('administer shortcuts'); @@ -196,8 +204,7 @@ public function submitForm(array &$form, array &$form_state) { } else { // Switch to a different shortcut set. - $sets = $this->storageController->load(array($form_state['values']['set'])); - $set = reset($sets); + $set = $this->storageController->load($form_state['values']['set']); $replacements = array( '%user' => $this->account->label(), '%set_name' => $set->label(), @@ -219,7 +226,7 @@ public function submitForm(array &$form, array &$form_state) { * TRUE if the shortcut set exists, FALSE otherwise. */ public function exists($id) { - $sets = $this->storageController->load(array($id)); + $sets = $this->storageController->loadMultiple(array($id)); return !empty($sets[$id]); }