удаление роли
@param Role $role
@return bool
548934
public function revokeRole(Role $role): bool
    {
        return (new actions\RevokeRole($this->user, $role))->execute();
    }
777427
public function deleteAction(Request $request, Role $role): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('role', 'delete'));
        $form = $this->formFactory->deleteRole(
            new RoleDeleteData($role)
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (RoleDeleteData $data) {
                $role = $data->getRole();
                $this->roleService->deleteRole($role);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Role '%role%' removed.") */
                        'role.delete.success',
                        ['%role%' => $role->identifier],
                        'role'
                    )
                );

                return new RedirectResponse($this->generateUrl('ezplatform.role.list'));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->redirect($this->generateUrl('ezplatform.role.view', [
            'roleId' => $role->id,
        ]));
    }
1264081
public function destroy(Role $role, Request $request)
    {
        $this->deleteEntry($role, $request);

        return redirect_to_resource();
    }
1013405
private function createDeleteForm(Role $role)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('core_role_delete', array('id' => $role->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
422987
public function detachRole($role)
    {
        if (is_object($role)) {
            $role = $role->getKey();
        }

        if (is_array($role)) {
            $role = $role['id'];
        }

        $this->roles()->detach($role);

        self::clearCache();
    }
499625
public function hasAnyRole(...$roles) {
		foreach ($roles as $role) {
			if ($this->hasRole($role)) {
				return true;
			}
		}

		return false;
	}
354789
public function deleteRole($role)
    {
        $params = [
            'role' => $role,
        ];

        $body = $this->request(self::URI_AUTH_ROLE_DELETE, $params);

        return $body;
    }
1069175
public function removeRole($id, $role)
    {
        $user = $this->getUser($id);

        if (empty($user) || empty($role)) {
            return false;
        }

        // Remove the role from the $user['roles'] array.
        $user['roles'] = array_diff($user['roles'], [(string) $role]);

        return $this->saveUser($user);
    }
315715
public function attachRole($role)
    {
        return (!$this->getRoles()->contains($role)) ? $this->roles()->attach($role) : true;
    }
1324580
public function isGranted($user, $role)
    {
        if (true === $user->hasRole($role)) {
            return true;
        }

        $roleHierarchy = new RoleHierarchy($this->getRoleHierarchyRoles());

        $userRoles = array_map(function ($role) {
            return new Role($role);
        }, $user->getRoles());

        $roles = $roleHierarchy->getReachableRoles($userRoles);
        $roles = array_map(function (Role $role) {
            return $role->getRole();
        }, $roles);

        return in_array($role, $roles);
    }
1150665
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('slug', $role);
        }

        if (is_array($role)) {
            $roles = $this->getRoleSlugs();

            $intersection      = array_intersect($roles, (array) $role);
            $intersectionCount = count($intersection);

            return ($intersectionCount > 0) ? true : false;
        }

        return ! ! $role->intersect($this->roles)->count();
    }
32768
public function downgradeFromRole(Role $role): bool
    {
        $auth = \Yii::$app->getAuthManager();
        if ($auth->revoke($role, $this->id)) {
            return true;
        }
        return false;
    }
147317
public function addRole(Role $role)
    {
        if (!in_array($role, $this->roles)) {
            $this->roles[] = $role;
            return true;
        }
        return false;
    }
1190327
public function hasRole($role)
    {
        return is_null($this->roles) || in_array($role, $this->roles, true);
    }
641367
public function hasRole($role)
    {
        if (is_string($role)) {
            return $this->roles->contains('name', $role);
        }

        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->hasRole($r)) {
                    return true;
                }
            }

            return false;
        }

        return !!$role->intersect($this->roles)->count();
    }
484648
public function checkRole($role)
    {
        return $this->getRoles()->contains(function ($value) use ($role) {
            return $role == $value->id || Str::is($role, $value->slug);
        });
    }
1366823
public function Delete($RoleID = FALSE) {
		if(!$this->_Permission())
			return;

		$this->Title(T('Delete Role'));
      $this->AddSideMenu('dashboard/role');
      
      $Role = $this->RoleModel->GetByRoleID($RoleID);
      if ($Role->Deletable == '0')
         $this->Form->AddError('You cannot delete this role.');
      
      // Make sure the form knows which item we are deleting.
      $this->Form->AddHidden('RoleID', $RoleID);
      
      // Figure out how many users will be affected by this deletion
      $this->AffectedUsers = $this->RoleModel->GetUserCount($RoleID);
      
      // Figure out how many users will be orphaned by this deletion
      $this->OrphanedUsers = $this->RoleModel->GetUserCount($RoleID, TRUE);

      // Get a list of roles other than this one that can act as a replacement
      $this->ReplacementRoles = $this->RoleModel->GetByNotRoleID($RoleID);
      
      if ($this->Form->AuthenticatedPostBack()) {
         // Make sure that a replacement role has been selected if there were going to be orphaned users
         if ($this->OrphanedUsers > 0) {
            $Validation = new Gdn_Validation();
            $Validation->ApplyRule('ReplacementRoleID', 'Required', 'You must choose a replacement role for orphaned users.');
            $Validation->Validate($this->Form->FormValues());
            $this->Form->SetValidationResults($Validation->Results());
         }
         if ($this->Form->ErrorCount() == 0) {
            // Go ahead and delete the Role
            $this->RoleModel->Delete($RoleID, $this->Form->GetValue('ReplacementRoleID'));
            $this->RedirectUrl = Url('dashboard/role');
            $this->InformMessage(T('Deleting role...'));
         }
      }
      $this->Render();
   }