From 55070f00e7922084fbc57f361b981101430d1f50 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 8 Oct 2019 09:04:24 -0400 Subject: [PATCH] Fixes #210: Don't throw exception when deleting non-existant role --- src/Drupal/Driver/Cores/Drupal8.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Drupal/Driver/Cores/Drupal8.php b/src/Drupal/Driver/Cores/Drupal8.php index 119bac2d..cddb2e7a 100644 --- a/src/Drupal/Driver/Cores/Drupal8.php +++ b/src/Drupal/Driver/Cores/Drupal8.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\TermInterface; +use Drupal\user\RoleInterface; use Symfony\Component\HttpFoundation\Request; /** @@ -168,12 +169,9 @@ public function roleCreate(array $permissions) { */ public function roleDelete($role_name) { $role = user_role_load($role_name); - - if (!$role) { - throw new \RuntimeException(sprintf('No role "%s" exists.', $role_name)); + if ($role instanceof RoleInterface) { + $role->delete(); } - - $role->delete(); } /**