src/EventSubscriber/User/UserArchivedListener.php line 27
<?phpdeclare(strict_types=1);namespace App\EventSubscriber\User;use App\Entity\User;use App\Events\User\UserArchivedEvent;use App\Services\Transaction;use App\Services\Transaction\Exceptions\CheckerException;use Symfony\Component\EventDispatcher\Attribute\AsEventListener;#[AsEventListener(event: UserArchivedEvent::NAME, method: 'resetAccounts')]class UserArchivedListener{protected const COMMENT = 'User archived: #%s';public function __construct(private readonly Transaction\ResetService $resetService,) {}/*** @throws \Throwable* @throws CheckerException*/public function resetAccounts(UserArchivedEvent $event): void{$user = $event->getUser();$comment = $this->createComment($user);$this->resetService->performAccount($user->getMainAccount(), $comment);$this->resetService->performAccount($user->getGiftAccount(), $comment);}private function createComment(User $user): string{return sprintf(self::COMMENT, (string) $user->getId());}}