public function deleteAccount(ResourceEvent $event)
 {
     $resource = $event->getResource();
     if (!$resource instanceof UserInterface) {
         throw new \Exception('Invalid resource type (expected User, got ' . get_class($resource));
     }
     $resource->setEnabled(0);
     $resource->setLocked(1);
     $this->userManager->updateUser($resource);
 }
 private function checkRole($roleSuffix, ResourceEvent $event)
 {
     $resource = $event->getResource();
     $resourceName = $this->rm->getResourceName(get_class($resource));
     $roleName = 'ROLE_' . strtoupper($resourceName) . '_' . $roleSuffix;
     $isGranted = $this->authorizationChecker->isGranted($roleName);
     if (!$isGranted) {
         throw new AccessDeniedHttpException('User does not have role ' . $roleName);
     }
 }
 public function userCreated(ResourceEvent $event)
 {
     $rep = $this->rm->getRepository(new User());
     $admin = $rep->findOneByEmail('*****@*****.**');
     $notif = new Notification();
     $notif->setUser($admin);
     $notif->setText("Un nouvel utilisateur s'est inscrit");
     $notif->setType($event->getName());
     $notif->setDatas(array($event->getResource()));
     $this->rm->create($notif);
 }