Skip to content

Commit

Permalink
[Community] deletes user role on user delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Jul 6, 2022
1 parent bcc1d15 commit 1f19366
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions src/main/community/Subscriber/Crud/RoleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Claroline\AppBundle\API\Crud;
use Claroline\AppBundle\Event\Crud\CreateEvent;
use Claroline\AppBundle\Event\Crud\DeleteEvent;
use Claroline\AppBundle\Event\Crud\PatchEvent;
use Claroline\AppBundle\Event\StrictDispatcher;
use Claroline\CoreBundle\Entity\AbstractRoleSubject;
Expand Down Expand Up @@ -45,7 +44,6 @@ public static function getSubscribedEvents(): array
Crud::getEventName('create', 'post', Role::class) => 'postCreate',
Crud::getEventName('patch', 'pre', Role::class) => 'prePatch',
Crud::getEventName('patch', 'post', Role::class) => 'postPatch',
Crud::getEventName('delete', 'pre', Role::class) => 'preDelete',
];
}

Expand Down Expand Up @@ -111,17 +109,6 @@ public function postCreate(CreateEvent $event)
}
}

public function preDelete(DeleteEvent $event)
{
/** @var Role $role */
$role = $event->getObject();

if ($role->isReadOnly()) {
// abort delete
$event->block();
}
}

public function prePatch(PatchEvent $event)
{
/** @var Role $role */
Expand Down
2 changes: 1 addition & 1 deletion src/main/community/Subscriber/Crud/UserSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function preDelete(DeleteEvent $event)

if ($userRole) {
// this would have been better in the postDelete event, but the username has been changed
$this->crud->delete($userRole);
$this->crud->delete($userRole, [Crud::NO_PERMISSIONS]);
}
}

Expand Down

0 comments on commit 1f19366

Please sign in to comment.