Skip to content

Commit

Permalink
Fixes jhedstrom#210: Don't throw exception when deleting non-existant…
Browse files Browse the repository at this point in the history
… role
  • Loading branch information
bkosborne authored Oct 8, 2019
1 parent 65d70d0 commit 55070f0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Drupal/Driver/Cores/Drupal8.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit 55070f0

Please sign in to comment.