Issue #3262384 by manuel.adan: Assigned shortcut set is not cleaned on user removal
(cherry picked from commit 09913ad57fd360c0ec1eacc43af842f30b8c2cc9)merge-requests/1901/head
parent
dfe7fd83c6
commit
c20ea2ace6
|
@ -9,6 +9,7 @@ use Drupal\Component\Render\FormattableMarkup;
|
||||||
use Drupal\Core\Access\AccessResult;
|
use Drupal\Core\Access\AccessResult;
|
||||||
use Drupal\Core\Cache\Cache;
|
use Drupal\Core\Cache\Cache;
|
||||||
use Drupal\Core\Cache\CacheableMetadata;
|
use Drupal\Core\Cache\CacheableMetadata;
|
||||||
|
use Drupal\Core\Entity\EntityInterface;
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
use Drupal\Core\Url;
|
use Drupal\Core\Url;
|
||||||
use Drupal\shortcut\Entity\ShortcutSet;
|
use Drupal\shortcut\Entity\ShortcutSet;
|
||||||
|
@ -383,3 +384,11 @@ function shortcut_themes_installed($theme_list) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_ENTITY_TYPE_delete().
|
||||||
|
*/
|
||||||
|
function shortcut_user_delete(EntityInterface $entity) {
|
||||||
|
// Clean up shortcut set mapping of removed user account.
|
||||||
|
\Drupal::entityTypeManager()->getStorage('shortcut_set')->unassignUser($entity);
|
||||||
|
}
|
||||||
|
|
|
@ -185,6 +185,20 @@ class ShortcutSetsTest extends ShortcutTestBase {
|
||||||
$this->assertSame($default_set->id(), $current_set->id(), "Successfully unassigned another user's shortcut set.");
|
$this->assertSame($default_set->id(), $current_set->id(), "Successfully unassigned another user's shortcut set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests assign clearing on user removal.
|
||||||
|
*/
|
||||||
|
public function testShortcutSetUnassignOnUserRemoval() {
|
||||||
|
$new_set = $this->generateShortcutSet($this->randomMachineName());
|
||||||
|
|
||||||
|
$shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set');
|
||||||
|
$shortcut_set_storage->assignUser($new_set, $this->shortcutUser);
|
||||||
|
$this->shortcutUser->delete();
|
||||||
|
$current_set = shortcut_current_displayed_set($this->shortcutUser);
|
||||||
|
$default_set = shortcut_default_set($this->shortcutUser);
|
||||||
|
$this->assertSame($default_set->id(), $current_set->id(), "Successfully cleared assigned shortcut set for removed user.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests deleting a shortcut set.
|
* Tests deleting a shortcut set.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue