user.post_update.php 446 B

12345678910111213141516171819202122
  1. <?php
  2. /**
  3. * @file
  4. * Post update functions for User module.
  5. */
  6. use Drupal\user\Entity\Role;
  7. /**
  8. * Enforce order of role permissions.
  9. */
  10. function user_post_update_enforce_order_of_permissions() {
  11. $entity_save = function (Role $role) {
  12. $permissions = $role->getPermissions();
  13. sort($permissions);
  14. if ($permissions !== $role->getPermissions()) {
  15. $role->save();
  16. }
  17. };
  18. array_map($entity_save, Role::loadMultiple());
  19. }